Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

developit
Copy link
Member

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Jul 28, 2021

🦋 Changeset detected

Latest commit: 96db4d5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wmr Patch

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);
Copy link
Member

@JoviDeCroock JoviDeCroock Jul 28, 2021

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, ...

Copy link
Contributor

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

Copy link
Contributor

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!

@github-actions
Copy link
Contributor

github-actions bot commented Jul 28, 2021

Size Change: +372 B (0%)

Total Size: 769 kB

Filename Size Change
packages/wmr/wmr.cjs 731 kB +372 B (0%)
ℹ️ View Unchanged
Filename Size
examples/demo/dist/about/index.html 712 B
examples/demo/dist/alias-outside/index.html 692 B
examples/demo/dist/assets/Calendar.********.css 702 B
examples/demo/dist/assets/style.********.css 624 B
examples/demo/dist/chunks/alias-outside.********.js 137 B
examples/demo/dist/chunks/class-fields.********.js 213 B
examples/demo/dist/chunks/compat.********.js 15.3 kB
examples/demo/dist/chunks/hoofd.module.********.js 1.47 kB
examples/demo/dist/chunks/index.********.js 266 B
examples/demo/dist/chunks/json.********.js 238 B
examples/demo/dist/chunks/meta-tags.********.js 298 B
examples/demo/dist/chunks/prerender.********.js 2.43 kB
examples/demo/dist/class-fields/index.html 703 B
examples/demo/dist/compat/index.html 1.6 kB
examples/demo/dist/env/index.html 778 B
examples/demo/dist/error/index.html 707 B
examples/demo/dist/files/index.html 738 B
examples/demo/dist/index.********.js 7.65 kB
examples/demo/dist/index.html 770 B
examples/demo/dist/json/index.html 710 B
examples/demo/dist/lazy-and-late/index.html 713 B
examples/demo/dist/meta-tags/index.html 781 B

compressed-size-action

* implement focus-based reconnect

* Update client.js

* Create brown-gorillas-notice.md
ws.addEventListener('close', reconnect);
}

function reconnect() {
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants