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

Open
#16,851 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
devtools

Research direction

Start by reproducing the two cases in the issue: Local Explorer starts the object first, and idFromString() starts it first. Trace how Local Explorer starts a Durable Object and how later getByName() or idFromName() calls reach it; the report names no source files or tests. Done when a later named call returns the expected name, or Local Explorer starts the object without losing it.

Written by the indexing model from the issue text.

Description

bug product:durable-objects
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).
Dominant language
TypeScript
Stars
4.7k
Forks
1.7k
Avg merge
1d 22h
Merged PRs (30d)
282

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/workers-sdk

All issues in cloudflare/workers-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.