question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow Client to Handle Reload

See original GitHub issue

The current client implementation handles reloading by calling window.reload.

https://github.com/pikapkg/esm-hmr/blob/07bf62c2ff783a4ea3319c0b2baa3351b65c073c/src/client.ts#L16-L18

This doesn’t make sense for WebExtensions where reloading is done by calling runtime.reload. I’m sure there are other contexts where you’d want to customize the reload behavior also (electron?).

It would be great if there was an API to customize the implementation of this function.

Maybe something along the lines of

import.meta.hot.registerReloadHandler(() => {
  // do your reloading here
  browser.runtime.reload()
});

The default registered reload handler could be the location one to preserve existing behavior.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
FredKSchottcommented, Jan 15, 2021

Oh, I also wonder if this line is returning false in your electron environment: const isWindowDefined = typeof window !== 'undefined';

Which would then cause our normal reload function to do nothing instead of reloading:

function reload() {
  if (!isWindowDefined) {
    return;
  }
  location.reload(true);
}
0reactions
FredKSchottcommented, Jan 18, 2021

Thank you for the kind words!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trigger client-side reload in next.js - Stack Overflow
What we need is a client-side reload. The "getInitialProps" function should be called in the browser. So, how to do the client-side reload?...
Read more >
Allow User Reload - QlikView App Dev - Qlik Community
Hi All, How can a user be given the privilege to Reload the QVW report or QVW application i tried to use by,...
Read more >
Single Page Refresh for Client Side Data Server Side
You might be tempted to just test if the cookie is set, and if not, set it and reload. PHP and jQuery here...
Read more >
location.reload() - Web APIs | MDN
The reload may be blocked and a SECURITY_ERROR DOMException thrown. This happens if the origin of the script calling location.reload() ...
Read more >
Using the refresh token - Amazon Cognito - AWS Documentation
See the setRefreshThreshold() method of CognitoIdentityProviderClientConfig in the Amplify Android SDK reference. Your user's account itself never expires, as ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found