Skip to content

fix(runtime): owner-aware registry entry removal#72

Merged
john-royal merged 2 commits into
mainfrom
fix/registry-owner-aware-unregister
Jul 20, 2026
Merged

fix(runtime): owner-aware registry entry removal#72
john-royal merged 2 commits into
mainfrom
fix/registry-owner-aware-unregister

Conversation

@sam-goodwin

Copy link
Copy Markdown
Contributor

A replacement instance of the same script re-registers under the same registry key. When the superseded instance's scope closes afterwards (a make-before-break handoff), its unregister finalizer deleted {scriptName}.json — unregistering the live replacement and breaking cross-script resolution.

Removal (both the scope finalizer and the exit hook) is now owner-aware — it only deletes the file while it still holds that write's content:

Effect.addFinalizer(() =>
  fs.readFileString(entryPath).pipe(
    Effect.flatMap((current) =>
      current === serialized ? fs.remove(entryPath) : Effect.void,
    ),
    Effect.ignore,
    Effect.andThen(Effect.sync(() => unregister())),
  ),
);

This unblocks reordering alchemy's local dev serve path back to make-before-break (start the replacement workerd before tearing down the previous instance), which alchemy-run/alchemy#812 had inverted precisely because unregister could delete the replacement registration. See alchemy-run/alchemy#859.

sam-goodwin and others added 2 commits July 17, 2026 13:34
…s typed error/requirement channels

The dts bundler cannot name the inferred Credentials requirement from
@distilled.cloud/cloudflare and degraded make/layer (and everything
composed from them, e.g. RuntimeServices.layerRuntime) to any/any.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A replacement instance of the same script re-registers under the same
registry key. When the superseded instance's scope closes afterwards (a
make-before-break handoff), its unregister finalizer previously deleted
{scriptName}.json — unregistering the live replacement and breaking
cross-script resolution. Removal (both the scope finalizer and the exit
hook) now only deletes the file while it still holds that write's content.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alchemy-version-bot

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

@distilled.cloud/cloudflare-rolldown-plugin

bun add https://pkg.distilled.cloud/cloudflare-rolldown-plugin/6c2eebb

@distilled.cloud/cloudflare-runtime

bun add https://pkg.distilled.cloud/cloudflare-runtime/6c2eebb

@distilled.cloud/cloudflare-vite-plugin

bun add https://pkg.distilled.cloud/cloudflare-vite-plugin/6c2eebb

@john-royal
john-royal merged commit ca3ab56 into main Jul 20, 2026
11 checks passed
@john-royal
john-royal deleted the fix/registry-owner-aware-unregister branch July 20, 2026 15:21
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