Skip to content

fix(cloudflare): preserve dev worker registration on reload#812

Merged
john-royal merged 1 commit into
alchemy-run:mainfrom
utopyin:utopy/local-worker-binding-close-race-condition
Jul 13, 2026
Merged

fix(cloudflare): preserve dev worker registration on reload#812
john-royal merged 1 commit into
alchemy-run:mainfrom
utopyin:utopy/local-worker-binding-close-race-condition

Conversation

@utopyin

@utopyin utopyin commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

hi! I'm getting Worker "home-api-dev-utopy-ijmmtvj5spgzktlm" not found. Make sure the worker is running locally in the rpc response whenever the backend code of my Api worker changes. It looks like a race condition.

Here's what the agent thinks is happpening:

  1. API hot reload starts and registers the replacement worker.
  2. Alchemy then asynchronously closes the previous worker scope in LocalWorkerProvider.ts:221-225.
  3. The old scope finalizer deletes the registry file by worker name in Registry.ts:124-136.
  4. Because both versions share the same name, it deletes the new worker’s registration.
  5. The web worker’s service binding can no longer resolve the API and returns the reported 503.

This seems to have fixed it on my end, not sure if this is not a regression though

@utopyin utopyin marked this pull request as draft July 12, 2026 16:00
@utopyin utopyin marked this pull request as ready for review July 12, 2026 16:09
@john-royal john-royal changed the title fix(LocalWorkerProvider): preserve worker registration on reload fix(cloudflare): preserve dev worker registration on reload Jul 13, 2026
@john-royal john-royal merged commit 9864c8d into alchemy-run:main Jul 13, 2026
8 checks passed
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.

2 participants