-
-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Automatically reconnect to HMR with exponential backoff #785
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 96db4d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -31,6 +33,15 @@ function connect(needsReload) { | |||
|
|||
ws.addEventListener('message', handleMessage); | |||
ws.addEventListener('error', handleError); | |||
ws.addEventListener('close', reconnect); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also listen for something like focussing (or visibilitychange) the browser again. This removes the need for exponential backoff, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a great idea. Thtat's what I'm using to run my code for waking up ios wrapper app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the exponential dropoff with 30s limit will not solve the case for a sleep longer than 30s, but visibilitychange certainly would.
Thanks guys!
Size Change: +372 B (0%) Total Size: 769 kB
ℹ️ View Unchanged
|
* implement focus-based reconnect * Update client.js * Create brown-gorillas-notice.md
ws.addEventListener('close', reconnect); | ||
} | ||
|
||
function reconnect() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently reconnect only gets called once, should this be called again if establishing connection in connect(false)
fails?
No description provided.