-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[wrangler] fix: prevent repeated reloads with circular service bindings #4699
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
Conversation
🦋 Changeset detectedLatest commit: af72a72 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 |
|
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7422613647/npm-package-wrangler-4699You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7422613647/npm-package-wrangler-4699Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7422613647/npm-package-wrangler-4699 dev path/to/script.jsAdditional artifacts:npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7422613647/npm-package-miniflare-4699npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7422613647/npm-package-cloudflare-pages-shared-4699npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7422613647/npm-package-create-cloudflare-4699 --no-auto-updateNote that these links will no longer work once the GitHub Actions artifact expires.
| Please ensure constraints are pinned, and |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4699 +/- ##
==========================================
+ Coverage 75.58% 75.65% +0.06%
==========================================
Files 243 243
Lines 13096 13096
Branches 3375 3376 +1
==========================================
+ Hits 9899 9908 +9
+ Misses 3197 3188 -9
|
| const newServer = new MiniflareServer(); | ||
| miniflareServerRef.current = server = newServer; | ||
| server.addEventListener("reloaded", async (event) => { | ||
| await maybeRegisterLocalWorker(event, props.name); |
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.
So this is the crux of this fix, right?
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.
Kinda, we still register the local worker, just with the URL of the proxy worker, not the user worker. The proxy worker has a stable URL across reloads, breaking the reload loop.
5579115 to
af72a72
Compare
petebacondarwin
left a comment
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.
Nice! This works for me. I pulled it down and also tested locally.
|
To test this locally, I followed the procedure laid out in the PR description:
I was able to see that we got the reloads on main and not after this PR. |
|
To add some context after discussion with @mrbbot: This was a good fix to go in now but the real fix is to register the ProxyWorker with the Dev Registry in startDevWorker Phase 2. This fix will be reverted once that is implemented 👍 |
Fixes #4673.
What this PR solves / how to test:
[email protected]introduced a bug where starting multiplewrangler devsessions with service bindings to each other resulted in a reload loop. This change ensures Wrangler only reloads when dependentwrangler devsessions start/stop, by registering workers in the dev registry with the URL of the proxy worker, not the user worker.Using the user worker URL meant that when a dependent service was started, the original service picked up the change and restarted its user worker getting a new port. The original service registered this new port, which was picked up by the dependent service which itself restarted its user worker on a new port. This created a reload loop.
We're planning to slightly change how dev registry registration works as part of the later WaaL milestones. This should also help prevent these sorts of issues.
To test this, add the following to
fixtures/service-bindings-app......then run
pnpm devinfixtures/serivce-bindings-app. Bothwrangler devsessions should start up without entering into a reload loop.Author has addressed the following:
Note for PR author:
We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label
highlight pr reviewso future reviewers can take inspiration and learn from it.