Skip to content

[Bug]: urlcode dev rejects every reload while an extension is active, needing a full restart #777

Closed

Description

@jimhoyd

Problem

urlcode dev's hot reload never re-registers extensions, so once an extension host is active (--host-file), every project edit is rejected with Extension revision pin mismatch: <name> and the server keeps serving stale code until the whole process is restarted -- not just reloaded.

Root cause

packages/core/src/extensions.ts:635 checks assert(registration.projectSha256===context.projectSha256, \Extension revision pin mismatch: ${name}`). context.projectSha256is now derived automatically from--policyon everycreateRuntime()` call (#723), so it changes as soon as the project's derived revision changes.

registration.projectSha256, on the other hand, is fixed at the moment composeHost() first runs the extension's host() factory -- which happens once, when host.mjs is imported at process startup. reload() in packages/core/src/server.ts:302 only calls createRuntime(project, {..., ...runtimeOptions}) on a hot reload; it never re-runs composeHost() or asks an extension to re-register:

async function reload() {
  ...
  const next = await createRuntime(project, { local, log: emit, origin, ...runtimeOptions });
  ...
}

So the extension's startup-time pin never advances, while the project's live-computed pin does, and every subsequent edit is rejected once the two diverge.

Reproduction

Locked @jimhoyd/urlcode 0.6.2, Node 26.8.2, against a real project with an active extension (urlcode-ai's host.mjs, which activates the mcp extension):

export URLCODE_OPERATOR_POLICY="$HOME/.config/urlcode-ai/local-policy.json"
npx urlcode permissions --project app > "$URLCODE_OPERATOR_POLICY"
npx urlcode dev --project app --host-file host.mjs --host 127.0.0.1 --port 3000 --origin http://localhost:3000 --policy "$URLCODE_OPERATOR_POLICY"
# in another shell, touch any function file:
echo '// probe' >> app/functions/home.mjs

Observed on stderr:

{"event":"reload","status":"rejected"}
{"event":"reload_rejected","message":"Extension revision pin mismatch: mcp","serving":"<hash>"}

This reproduces on the very first edit after startup, every time, with no project change beyond the appended comment. urlcode permissions/regenerating the policy makes no difference -- the mismatch is between the extension's own registration snapshot and the live project revision, not the policy.

Expected behavior

A project edit that keeps every extension's own declared configuration unchanged should reload successfully, the same way it does with no --host-file. At minimum, reload() should re-run composeHost() (or otherwise refresh each extension's registration) before comparing revision pins, so the extension pin advances alongside the project's own, instead of only ever matching once, at process startup.

Impact

Any urlcode dev session with an extension active (the mcp extension in particular, since it's what serves /mcp for AI-authoring workflows) cannot hot-reload at all: every edit needs a full process restart. This makes the advertised dev loop effectively non-functional for extension-backed projects. Discovered while triaging jimhoyd-com/urlcode-ai#62, after confirming #723's project-level revision-pin fix (0.6.2) does not cover this separate extension-level pin.

Scope

Read-only source inspection (packages/core/src, not the built dist/ output) plus the reproduction above; no fix attempted here. Related: #723 (fixed the project-level pin, this repository, shipped in 0.6.2), #580 (made rejected reloads visible), jimhoyd-com/urlcode-ai#62 (downstream report of this exact friction).

Activity

  1. jimhoyd commented on Sep 26, 2026

    @jimhoyd
    CollaboratorAuthor

    Reopening after a 0.6.3 review: the revision-pin fix works for the synthetic extension and for URLCode AI's real MCP extension, but a normal published stateful composition still cannot reload.

    Revision/environment: core main/v0.6.3 2383b1213546fb9fd1fbc51aa4d2ed6dfe27a457, published 0.6.3 add-ons, macOS, Node 26.10.0. No production data.

    Reproduction:

    1. urlcode init <temporary-site> --with admin,form-records --example.
    2. Review/pin its initial revision and start dev with host.mjs and a canonical origin. In the isolated reproduction I called the same public startServer path with followExtensionPinOnReload: true, then its reload method.
    3. Change only the contact form's title from Contact us to Changed contact title in app/urlcode.yaml.
    4. Reload.

    Observed: reload returns false; reload.status is rejected. Diagnostic:

    Extension "store" failed to activate: Store directory is already locked by this process
    

    The last-good /contact page stays HTTP 200 with its old title. The new title never appears.

    server.ts constructs/activates the replacement runtime before closing the old one. packages/store/src/store.ts acquires its exclusive directory lock during every activation, so the existing instance prevents that replacement activation. Following the extension revision removes the earlier refusal but exposes this lifecycle conflict. The fresh app uses real released store/auth/forms/form-records packages; the added #777 tests' synthetic extension does not exercise it.

    Please cover the generated stateful composition in reload tests and define a lifecycle/handoff that retains single-writer safety and the last-good snapshot on failure. Do not simply remove the store lock or blindly unlock the active instance. The unmodified 0.6.3 full verify passes (964 core tests, 715 workspace tests and four packed integration tests).

  2. added
    bug
    extension
    important
    on Sep 26, 2026
  3. added 2 commits that reference this issue on Sep 26, 2026
    d7babfe
    361e2de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugextensionimportant

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions