Skip to content

fix: DurableObjectState publishes only workerd's members (#256) - #260

Merged
ryuzdev merged 1 commit into
mainfrom
fix/do-state-private
Nov 24, 2026
Merged

ryuzdev merged 1 commit into
mainfrom
fix/do-state-private

Conversation

@ryuzdev

@ryuzdev ryuzdev commented Nov 24, 2026

Copy link
Copy Markdown
Member

Closes #256

DurableObjectState.prototype carried _ready, _socket, _blockConcurrencyWhile, _runConcurrencyBlock and _resetAfterConcurrencyFailure: non-enumerable, but reachable from guest code, and workerd has none of them. Left by #254 as a separate refactor.

Change

  • The five are #-private instance methods now. The class's static block hands the runtime the three entry points it reaches from outside (__stateReady, __stateSocket, __stateFailBlock), which replace the call sites in _readyInstance, the four __ws* dispatch paths and process.exit. The bodies are unchanged, so nesting, the 30-second limit, the nested-block drain, the failure reset and hibernatable WebSocket dispatch are the same code — this is a surface change, not a behavioural one.
  • The state's prototype members are enumerable as workerd's are (__webidlPrototype(DurableObjectState)), so Object.keys and Object.getOwnPropertyNames of the prototype answer workerd's list.

Verification

  • Gate: new do/state-surface (233 total) pins the tag, enumerable own keys, the sorted prototype chain, the absence of every internal name (Object.getOwnPropertyNames(proto) has no _ member and typeof ctx._ready is undefined) and a nested blockConcurrencyWhile through the public API. It DIVERGES on the parent commit (5590070); on this head all 233 cases agree.
  • cargo test --profile ci --locked -p cello --no-fail-fast exit 0, 66 suites ok (covers block concurrency, transactions, hibernatable sockets and disconnect retention).
  • cargo clippy --profile ci --locked --all-targets -- -D warnings, cargo fmt --check, node scripts/check-docs.mjs clean.
  • Rebasing onto main after fix: Durable Object and D1 surface leftovers match workerd (#251) #254 merged needed no manual resolution.

Docs: changelog #256 entry; cloudflare-compat.md records that the state no longer publishes host-internal members and that ctx.facets is the only object left with _-prefixed prototype helpers (non-enumerable, unsupported, out of this issue); the Durable Objects reflection row is updated.

- `_blockConcurrencyWhile`, `_runConcurrencyBlock`, `_resetAfterConcurrencyFailure`,
  `_ready` and `_socket` were non-enumerable members of the state's prototype,
  reachable from guest code; workerd has none of them. They are `#`-private
  instance methods now, and the class's static block hands the runtime the
  three closures it needs (`__stateReady`, `__stateSocket`, `__stateFailBlock`).
  The bodies are unchanged, so nesting, the 30-second limit, the nested-block
  drain, the failure reset and hibernatable socket dispatch keep their
  semantics; this is a surface change, not a behavioral one.
- The state's prototype members are enumerable as workerd's are, so
  `Object.getOwnPropertyNames(Object.getPrototypeOf(ctx))` and
  `Object.keys` of it answer workerd's list.
- The differential gate gains `do/state-surface` (233 total): it pins the
  tag, own keys, prototype chain, the absence of every internal name and a
  nested block through the public API. It fails on the parent commit.
- Docs: changelog entry, cloudflare-compat.md (the state is clean; `ctx.facets`
  is the remaining object with host-internal prototype helpers), and the
  Durable Objects reflection row.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6741685-6985-41e0-b99c-e7e90fe7483f
Commits

Reviewing files that changed from the base of the PR and between b55232d and 060334f.

Files selected for processing: 7

  • crates/cello/js/harness.js
  • crates/cello/js/storage_ops.rs
  • docs/changelog.md
  • docs/reference/cloudflare-compat.md
  • docs/services/durable-objects.md
  • scripts/workerd-diff/cases.mjs
  • scripts/workerd-diff/corpus/do/index.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ryuzdev
ryuzdev merged commit 77f35cd into main Nov 24, 2026
9 checks passed
@ryuzdev
ryuzdev deleted the fix/do-state-private branch November 24, 2026 15:25
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.

workerd diff: DurableObjectState keeps _ready/_socket/_blockConcurrencyWhile internals on its prototype

1 participant