[wrangler] Fix remote bindings hanging on shutdown#13887
Conversation
🦋 Changeset detectedLatest commit: 5fdb554 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
✅ All changesets look good |
|
I've now reviewed the entire PR. Let me analyze the changes: The fix ( The test (
The changeset: Correctly scoped to The code change is a one-line, well-targeted fix for a real closure capture bug. The test adequately covers the scenario. The changeset is appropriate. LGTM |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
… reference after auth re-registration
d85f9af to
df51238
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers |
dario-piotrowicz
left a comment
There was a problem hiding this comment.
Looks good to me! (I feel that this bug as actually caused by me! 😅) Thanks @apeacock1991 😄
Could you maybe just expand on the changeset if possible? 🙏
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Fixes #11254
startDev() registers dev hotkeys before authenticating the user. During interactive dev sessions, the auth callback re-registers hotkeys, which updates the local unregisterHotKeys variable to a new cleanup function. However, the unregisterHotKeys value returned to callers was captured as a direct reference to the initial registration, so it would call the stale cleanup function instead of the current one.
This PR fixes the bug by returning a wrapper function () => unregisterHotKeys?.() instead of the variable directly. The wrapper evaluates unregisterHotKeys at call time, ensuring it always invokes the latest cleanup function even after re-registration.
A unit test is added to verify that unregisterHotKeys() correctly calls the latest cleanup after auth triggers a re-registration.