workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

Local Explorer starts a Durable Object without ctx.id.name, and later named calls do not restore it

Open mynk-tmr opened this issue 3 weeks ago • 1 comments

Summary

If the Local Explorer (or any idFromString() call) is the first thing to start a Durable Object, ctx.id.name stays undefined for the whole life of that instance. Later requests that reach the object by name (getByName() / idFromName()) do not restore it. A restart of wrangler dev clears it.

The docs say ctx.id.name is undefined when the object is reached through idFromString() (changelog). This report is about what happens after that: the name is still missing on later calls that do have the name.

Reproduction

Minimal project: one Worker, one SQLite-backed DO with whoami() { return { name: this.ctx.id.name ?? null } }. Routes: /hex-of/:name (returns idFromName(name).toString(), does not start the object), /by-name/:name (getByName(name).whoami()), /by-hex/:hex (get(idFromString(hex)).whoami()).

wrangler 4.160.1, compatibility_date 2026-03-20, macOS arm64.

Case 1 - Local Explorer starts the object first

  1. HEX=$(curl -s localhost:8799/hex-of/carol | jq -r .hex) (id only, no object is started)
  2. Open http://localhost:8799/cdn-cgi/local/explorer/do/Counter/$HEX in a browser.
  3. curl localhost:8799/by-name/carol returns {"name":null,...}. Expected "carol".

Case 2 - no explorer, idFromString() first

  1. HEX=$(curl -s localhost:8799/hex-of/alice | jq -r .hex)
  2. curl localhost:8799/by-hex/$HEX returns {"name":null} (documented).
  3. curl localhost:8799/by-name/alice returns {"name":null}. Expected "alice".

Control - named call first /by-name/bob returns "bob", and a later /by-hex/<bob's hex> still returns "bob". So the first caller decides, and it is never updated.

Expected

Either a later call through idFromName() / getByName() restores ctx.id.name, or the Local Explorer starts the object in a way that keeps the name.

Impact

Code that reads ctx.id.name in a method (as the docs recommend) throws or misbehaves for the rest of the dev session after one look at the object in the Local Explorer. We hit this with a DO whose id is its name: opening it in the explorer broke every later app request to it until wrangler dev was restarted.

Notes

  • Not tested in production; I only know of the local behavior.
  • Possibly related: cloudflare/workerd#7286 (proxy drops ctx.id.name).

mynk-tmr avatar Nov 12 '26 10:11 mynk-tmr

Automated triage

Issue assessment

  • Actionability: ✅ Actionable.
  • Type: Bug.
  • Reproduction: Automatic attempt requested.
  • Labels:
    • bug (high)
    • product:durable-objects (high)
    • feature:local-explorer (medium)
    • package:wrangler (medium)
    • upstream:workerd (low)
Actionability and missing information

Bug: in wrangler 4.160.1 local dev, a DO first started via the Local Explorer or idFromString keeps ctx.id.name unset for the instance lifetime and later getByName calls do not restore it; minimal repro, steps, environment, expected and actual behavior are all supplied, so it is actionable.

Reproduction reason: The report supplies a minimal single-worker project with named routes, exact curl steps for failing and control cases, wrangler version, and OS, describing a current local-dev behavior defect that can be attempted.

Reproduction

  • Result: ✅ Reproduced.
  • Summary: Reproduced on wrangler 4.160.1 local dev: after idFromString() first starts a SQLite DO instance, later getByName()/get(idFromName()) calls return ctx.id.name=null on that same instance; a named call first pins the name (control ok). Explorer needs a browser; only attempted headlessly.
Evidence and attempted steps

Steps attempted:

  1. Create a minimal Worker fixture (SQLite Durable Object class Counter extending DurableObject with whoami() returning ctx.id.name, plus /hex-of, /by-name, /by-id-from-name and /by-hex routes; wrangler.toml with compatibility_date 2026-03-20) and install wrangler 4.160.1
    • Command: cd /workspace/reproduction-output/project && pnpm install
  2. Run reproduce.sh: start wrangler dev on 127.0.0.1:8799; request /hex-of/alice, then /by-hex with that hex, then /by-name/alice and /by-id-from-name/alice; control with bob; then a fresh session attempting the Local Explorer URL via curl with carol
    • Command: pnpm reproduce

Expected behavior: After a Durable Object is first started via idFromString() (e.g. by opening it in the Local Explorer), a later request that reaches the object by name (getByName() or get(idFromName())) should set/restore ctx.id.name, so /by-name/alice returns the name "alice". Control: /by-name/bob first returns "bob", and a later by-hex request for bob's hex id still returns "bob".

Observed behavior: Reproduced the report exactly with wrangler 4.160.1 (bundled workerd 1.20261110.1): GET /hex-of/alice returned the hex id without starting the object; the by-hex request started the instance at 2026-11-12T10:06:06.166Z with name null; subsequent /by-name/alice and /by-id-from-name/alice both returned name null from the SAME in-memory instance (identical startedAt and id), so the name was never set for the rest of the dev session. Control matched the issue: /by-name/bob returned "bob" (instance 10:06:06.214Z) and a later by-hex request for the same object still returned "bob" — first caller decides, never updated. Restarting wrangler dev between sessions cleared it, as reported.

Artifact: Download reproduction archive (Cloudflare Access required).

Treat archive contents as untrusted. Inspect them before running anything.


This summary was generated by an LLM and may contain errors. Please verify its findings.

Triage bot commands and options

Repository collaborators with write or admin access can trigger actions by commenting on this issue:

  • @workers-devprod reproduce: Attempt to reproduce the issue using its description and recent comments.

workers-devprod avatar Nov 12 '26 10:11 workers-devprod