Skip to content

fix(platform): rate node scheduler and alarms unsupported — jobs are never dispatched - #321

Closed
prisis wants to merge 3 commits into
alphafrom
fix/platform-node-capability-honesty
Closed

prisis wants to merge 3 commits into
alphafrom
fix/platform-node-capability-honesty

Conversation

@prisis

@prisis prisis commented Aug 2, 2026

Copy link
Copy Markdown
Member

Work from an agent worktree, pushed under a descriptive name (local branch was worktree-agent-a3e2c22e70fd79ddf).
Branched before #288/#289 landed, so it needs a rebase onto current alpha before merge.

Commits

  • fix(platform): rate node scheduler and alarms unsupported — jobs are never dispatched
  • fix(platform-node): make close() terminal and serialize transaction
  • test(platform): give the conformance TCK teeth — dispatch, real skips, safe cleanup

prisis added 3 commits August 1, 2026 17:04
…never dispatched

The Node host's scheduler and shard-alarm timers only ever clear their own
bookkeeping on fire — nothing dispatches the scheduled function or wakes an
alarm callback. Rating both "emulated" let codegen's fail-closed gate pass
ctx.scheduler through silently for target: "node" apps whose scheduled work
would never run; "emulated" means built on lower-level primitives and
working, which never-dispatched is not.

Flip both to "unsupported" in NODE_CAPABILITIES so codegen omits the surface
and emits platform_unsupported_feature instead. Drop the scheduler's
deadLetter member (and simulateDeadLetter): its presence is the contract's
documented at-least-once claim, and this host cannot back it. Document that
shardAlarms has no CapabilityKey to gate through codegen's usage map — it is
engine-internal, never an app import — so the rating exists for Studio parity
reporting rather than codegen gating.

Update the codegen golden test to expect scheduler gated off.
Two latent lifecycle/correctness bugs in the Node host, both hardened here
together since they share node-shard-host.ts:

- close() was not a terminal state: after tearing a NodePlatform down,
  scheduler.schedule() armed a fresh setTimeout nothing would ever clear,
  scheduler.list()/cancel() kept reporting stale jobs, and alarms.set()
  mutated in-memory state before throwing on the closed connection. Every
  mutating call now checks closed-ness first (the connection's own open
  state for alarms, a dedicated flag for the scheduler) and throws before any
  mutation; reads/cancels answer emptied/false rather than throwing, so
  teardown-order races stay benign.

- transaction() ran raw BEGIN/COMMIT/ROLLBACK directly against the shared
  connection with no serialization of its own. Two overlapping transaction()
  calls could throw "cannot start a transaction within a transaction" or,
  worse, let one's COMMIT commit the other's uncommitted writes. Routing
  transaction through the existing runSerialized queue would deadlock (the
  engine already composes runSerialized(() => transaction(work))), so this
  adds a second, private transactionTail chain of the identical shape, used
  only by transaction — bare overlapping calls now serialize against each
  other instead of corrupting commits, and the engine's composition stays
  deadlock-free. Same fix applied to the reference host, which has the
  identical shape.

New lifecycle legs and a transaction-concurrency test on both hosts; each was
confirmed to fail against the pre-fix code (stashed and re-run) before this
commit.
…, safe cleanup

The host-contract TCK could not fail for the failures that mattered most:

- No leg ever asserted a scheduled job was actually dispatched — only that
  scheduling math was right and an id existed. A host that stores jobs and
  drops them on the floor (exactly what both the Node and reference hosts did
  pre-267) passed every scheduler leg, dead-letter legs included. Add
  ConformanceHost.awaitJobDispatched (optional, but mandatory for a host that
  declares scheduler.deadLetter — the contract's at-least-once claim), make
  the reference host observably dispatch (a dispatchedJobs set populated from
  its scheduler timer, not just bookkeeping deletion), and add a leg that
  fails a host claiming deadLetter without provable dispatch rather than
  skipping it.

- 14 optional-tier branches padded expect(true).toBe(true) (or a
  self-evident toBeUndefined()) instead of skipping, so a host exercising 20
  of 28 legs still reported "28 passed". Replaced every one with vitest's
  dynamic context.skip(), moving each leg's expect.assertions() below the
  tier check. The workerd adapter (itInDurableObject) now forwards the real
  TestContext into the suite body so context.skip() reaches a runner that
  recognizes it.

- All 43 host.cleanup?.() calls were bare trailing statements, never in a
  finally — a failing assertion above one skipped cleanup, leaking the
  alarm/scheduler setTimeouts (and, on a file-backed host, the open
  connection). Introduced a withHost(run) wrapper that guarantees cleanup on
  every path (assertion failure, context.skip(), or return) without an
  afterEach, which the workerd call site's runInDurableObject scoping rules
  out.

Also added "keeps overlapping transactions atomic" to the ShardHost block,
pinning plan 267's transactionTail fix suite-wide (including against the
real Cloudflare host over storage.transaction).

Verified per-host outcome: reference host 43/43 green, 0 skips (implements
every optional tier). Node host 50 passed, 4 skipped (the delivery leg plus
the three dead-letter legs it no longer claims post-267). Cloudflare
(@lunora/do, LUNORA_WORKERD_TESTS=1) 570 passed, 12 skipped (2 recycle + 1
mutable-tag + 9 scheduler legs — it has no scheduler at all), 0 failed. Each
new/changed behavior was demonstrated against pre-fix code before landing:
the delivery leg fails a host with deadLetter but no observable dispatch,
and a deliberately broken assertion in the rollback leg produces a prompt
red exit instead of a handle-leak hang.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@prisis, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 78dfe686-4096-4710-9ddd-6f522cb28cea

📥 Commits

Reviewing files that changed from the base of the PR and between 6a4dd72 and 8fca547.

⛔ Files ignored due to path filters (5)
  • packages/codegen/__tests__/platform-target.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
  • packages/do/__tests__/workerd/cloudflare-host.workerd.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
  • packages/platform-node/__tests__/lifecycle.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
  • packages/platform-node/__tests__/transaction-concurrency.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
  • packages/platform/__tests__/reference-host-transaction.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
📒 Files selected for processing (8)
  • packages/codegen/src/platform-target.ts
  • packages/platform-node/src/conformance/index.ts
  • packages/platform-node/src/node-platform.ts
  • packages/platform-node/src/node-scheduler-host.ts
  • packages/platform-node/src/node-shard-host.ts
  • packages/platform/src/capabilities.ts
  • packages/platform/src/conformance/reference-host.ts
  • packages/platform/src/conformance/suite.ts

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

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for lunorash failed.

Name Link
🔨 Latest commit 8fca547
🔍 Latest deploy log https://app.netlify.com/projects/lunorash/deploys/6a6f0c14fa2ad40009be39e2

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for confirming the Contributor License Agreement! 🙏

@prisis

prisis commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

Closing: this PR was opened in error by an automated run, outside the scope of its task.

No work is lost — the branch is retained on origin and this PR can be reopened at any time.

Context: this branch predates the merges of #288 and #289, so much of its content is already on alpha, and it would need a rebase before being reviewable. Reopening deliberately, after a rebase, is preferable to leaving it open in this state.

@prisis prisis closed this Aug 2, 2026
@prisis
prisis deleted the fix/platform-node-capability-honesty branch August 2, 2026 09:47
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using our GitHub Discussions tab for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant