Skip to content

Upgrade workerd to 1.20261123.1 and skip the slow-timer releases - #245

Merged
ruifigueira merged 8 commits into
mainfrom
rfigueira/bump-workerd
Nov 26, 2026
Merged

ruifigueira merged 8 commits into
mainfrom
rfigueira/bump-workerd

Conversation

@ruifigueira

Copy link
Copy Markdown
Collaborator

Summary

Upgrade the local workerd from 1.20260911.1 to 1.20261123.1, and finish the follow-ups from #230.

The upgrade skips every workerd release from 1.20260917 to 1.20261115. In those releases, workerd's local event loop runs on tokio, which holds each zero-delay timer until its next 1 ms tick. Each setTimeout(0) takes about 1.1 ms instead of microseconds. cloudflare/workerd#8476 fixed this in 1.20261116.1. Production uses a different event loop and is not affected. This bug caused most of the evaluate floor reported in #164: the 8 ms in that issue was measured on 1.20260929.1.

The follow-up from #230: while the page-task pump is paused (during a PDF stream), an evaluate no longer waits out three 50 ms task turns that cannot run anything.

Behavior and API impact

None for CDP results. Two local-runtime changes:

  • An evaluate during a PDF stream replies about 150 ms sooner. Page tasks queued during the pause still run after it ends.
  • The Docker image's front.js collapses repeated slashes before it looks up a file in public/. workerd's disk service now returns 404 for a path with an empty segment, so without this change, //fonts/a.txt would go to the engine instead of being served.

Implementation

  1. Upgrade workerd to 1.20261123.1. This moves miniflare to 5.20261123.1-beta, wrangler to 4.168.0 and @cloudflare/vitest-plugin to 1.9.2, which all resolve workerd 1.20261123.1, and @cloudflare/workers-types to match. Compatibility dates are unchanged. The page bundlers stay on esbuild 0.27.7. Two changes follow from the upgrade:
    • wrangler types now declares the *.wasm and *.glue.js modules in the generated worker-configuration.d.ts. That made packages/engine/src/wasm-modules.ts a duplicate (TS2300), so this PR removes it.
    • docker/front.js collapses repeated slashes, as described above.
  2. Rebaseline streams/transferable/transform-stream-members.any.html, FAIL→PASS, in its own commit. On 1.20261123.1, structuredClone throws DataCloneError when the transfer list holds a TransformStream and one of its own streams.
  3. yieldToDuePageTasks returns after one native macrotask while the pump is paused. A paused pump arms no wake, so each turn only waited out the 50 ms grace cap in yieldToPageTasks. The comment no longer prices a turn at ~1.3 ms, which came from the timer bug above. The e2e test name now says it covers both chain lengths.

Validation

Evaluate latency. I ran the script from #164 (200 sequential Runtime.evaluate("1+2") calls on a static page) against scripts/wpt-engine.mjs serve, with the workerd binary selected through MINIFLARE_WORKERD_PATH. This was local, on macOS arm64. "Before #230" is 0affe70, and "after #230" is this branch's code. The 1.20260911.1 row is main today, and the 1.20261125.1 "after" row is this PR. The table shows p50 values. DOM.getDocument took about 0.17 ms in every run.

workerd before #230 after #230
1.20260911.1 (current pin) 0.46 ms 0.40 ms
1.20260929.1 (has the timer bug) 6.12 ms 1.51 ms
1.20261125.1 (has the fix) 1.43 ms 0.57 ms

200 sequential await setTimeout(0) calls in a plain Worker take 3 ms on 1.20260911.1, 227 ms on 1.20260929.1 and 39 ms on 1.20261125.1.

Benchmark method and raw output

Build one dist for each side, then serve each dist on each workerd binary (@cloudflare/workerd-darwin-arm64@<version> from npm):

node scripts/wpt-engine.mjs prepare --dist <dist>    # at 0affe70c9, then at this branch
MINIFLARE_WORKERD_PATH=<workerd-binary> node scripts/wpt-engine.mjs serve \
  --port <port> --dist <dist> --var KITESURF_ALLOW_PRIVATE_NETWORK:1
node eval-floor.mjs ws://127.0.0.1:<port>/devtools/browser "" 200   # the script from #164
== workerd 1.20260911.1, before #230
   Runtime.evaluate("1+2")              p10 0.37  p50 0.46  p90 0.80 ms  (n=200)
   DOM.getDocument (comparison)         p10 0.15  p50 0.18  p90 0.21 ms  (n=200)
== workerd 1.20260911.1, after #230
   Runtime.evaluate("1+2")              p10 0.32  p50 0.40  p90 0.81 ms  (n=200)
   DOM.getDocument (comparison)         p10 0.15  p50 0.17  p90 0.21 ms  (n=200)
== workerd 1.20260929.1, before #230
   Runtime.evaluate("1+2")              p10 4.93  p50 6.12  p90 7.54 ms  (n=200)
   DOM.getDocument (comparison)         p10 0.15  p50 0.17  p90 0.22 ms  (n=200)
== workerd 1.20260929.1, after #230
   Runtime.evaluate("1+2")              p10 1.45  p50 1.51  p90 1.74 ms  (n=200)
   DOM.getDocument (comparison)         p10 0.15  p50 0.17  p90 0.22 ms  (n=200)
== workerd 1.20261125.1, before #230
   Runtime.evaluate("1+2")              p10 1.08  p50 1.43  p90 1.86 ms  (n=200)
   DOM.getDocument (comparison)         p10 0.14  p50 0.17  p90 0.29 ms  (n=200)
== workerd 1.20261125.1, after #230
   Runtime.evaluate("1+2")              p10 0.51  p50 0.57  p90 0.84 ms  (n=200)
   DOM.getDocument (comparison)         p10 0.15  p50 0.17  p90 0.22 ms  (n=200)

The timer microbenchmark is a plain Worker run with workerd serve on each version:

export default {
  async fetch() {
    const tick = () => new Promise((r) => setTimeout(r, 0));
    const t0 = Date.now();
    for (let i = 0; i < 200; i++) await tick();
    return Response.json({ total200ms: Date.now() - t0 });
  },
};
1.20260911.1: {"total200ms":3}
1.20260929.1: {"total200ms":227}
1.20261125.1: {"total200ms":39}

1.20261125.1 stands in for 1.20261123.1, the version this PR pins. Both include cloudflare/workerd#8476.

Paused pump. The new case in packages/engine/test/page-task-yield.test.ts, "takes no task turn for a due task while the pump is paused", fails on main: it takes 3 turns in 156 ms. It passes on this branch.

Disk service. On 1.20260911.1, the disk service returns 200 for //fonts/a.txt and /fonts//a.txt. On 1.20261116.1 and 1.20261125.1, it returns 404 for both. scripts/workerd-config.test.mjs caught this. It fails on the upgrade without the front.js change and passes with it.

Commands:

  • pnpm run check: passed on the upgrade alone, on the combined branch, and after rebasing onto 1b9e537.
  • bazel test //packages/engine:vitest: passed on all three shards.
  • pnpm run test:e2e --maxWorkers=4 eval timer console cookie navigat screenshot worker websocket fetch message-channel microtask pdf font local-storage iframe connect target: 114 files, 277 passed, 1 skipped.
  • pnpm run test:e2e --maxWorkers=4 eval timer microtask pdf console message-channel settle webmcp on the combined branch: 35 files, 63 passed.
  • pnpm run test:wpt --filter <dir> for html/webappapis, dom/events, webmessaging, streams, xhr/, workers/, fetch/api/basic and FileAPI. I ran the same filters on main, which shows the same local deviations, except for two tests:
    • transform-stream-members passes in 3/3 runs on the new workerd and fails in 3/3 on main. This PR rebaselines it.
    • dom/events/Event-dispatch-single-activation-behavior.html finishes as FAIL in 6/6 local runs on the new workerd and 2/6 on main. Its expectation pins TIMEOUT for CI on purpose, so I left it alone.

What I could not check:

  • The Playwright and Puppeteer lanes. Locally, the Playwright runner is killed by SIGKILL before it reports, on main as well. This PR relies on CI for both lanes.
  • The full WPT gate. If it reports TIMEOUT→FAIL for Event-dispatch-single-activation-behavior.html, that test needs a rebaseline.
  • The latency numbers on Linux, and on Cloudflare's deployed runtime.

Risks and follow-ups

  • The upgrade spans two months of workerd, miniflare (alpha to beta), wrangler (4.131 to 4.168) and the vitest plugin (1.1 to 1.9). The e2e and WPT subsets above pass, but the full lanes have not run yet.
  • Zero-delay timers on 1.20261123.1 are still slower than on 1.20260911.1, so evaluate goes from 0.40 ms to 0.57 ms p50 locally. That costs much less than any release between them would.
  • A later upgrade must not land on a release between 1.20260917 and 1.20261115.

Checklist

beep-boop-🤖

@github-actions github-actions Bot added the vouch:trusted Author is vouched, a collaborator, or a bot. label Nov 26, 2026
@BernardoPe BernardoPe assigned BernardoPe and unassigned BernardoPe Nov 26, 2026
@BernardoPe

Copy link
Copy Markdown
Collaborator

beep-boop-bernardo-agent-🤖

No blocking findings.

Agent review: APPROVE sha=506115288ddc8bed4a2091b070eee04f66ab231d

@BernardoPe BernardoPe added the Ready for human review An independent agent reviewed this exact commit and found nothing blocking label Nov 26, 2026
@BernardoPe BernardoPe removed their assignment Nov 26, 2026
Local engines ran workerd 1.20260911.1 through miniflare, wrangler and
the vitest plugin. Move them to miniflare 5.20261123.1-beta, wrangler
4.168.0 and @cloudflare/vitest-plugin 1.9.2, which all resolve workerd
1.20261123.1, and workers-types to match.

Skip the releases between them. From 1.20260917 workerd's local event
loop runs on tokio, which held every zero-delay timer until its next
1 ms tick, so each setTimeout(0) took about 1.1 ms instead of
microseconds (cloudflare/workerd#8476, fixed in 1.20261116.1). That is
the evaluate floor in #164: 200 zero-delay timers take 3 ms on
1.20260911.1, 227 ms on 1.20260929.1 and 39 ms on 1.20261123.1.

Two changes follow from the upgrade:

- wrangler types now declares the "*.wasm" and "*.glue.js" modules in
  the generated worker-configuration.d.ts, so the engine's own
  declarations in src/wasm-modules.ts were duplicates (TS2300).
- workerd's disk service now answers 404 for a path with an empty
  segment, where it used to collapse it. The Docker image's front.js
  collapses repeated slashes before it asks for a public/ file, so
  //fonts/a.txt is still served (scripts/workerd-config.test.mjs).

Compatibility dates are unchanged.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
….20261123.1

The test transfers a TransformStream together with its own readable or
writable side and expects structuredClone to throw DataCloneError.
workerd 1.20261123.1 throws it; 1.20260911.1 did not. It passes in
every run on the new workerd and fails in every run on the old one.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
While pausePageTaskPump holds page tasks (the PDF scene stream), a
task queued in the meantime makes pageTimerDueWithin(0) true, so
yieldToDuePageTasks took a wheel turn. A paused pump arms no wake, so
each turn only waited out yieldToPageTasks' 50 ms grace cap: an
evaluate during a PDF stream replied about 150 ms late and ran no page
task anyway. It now drains microtasks, takes the one native macrotask
and returns.

The comment no longer prices a wheel turn at ~1.3 ms. That cost came
from workerd's tokio event loop, which held every zero-delay timer
until its next 1 ms tick (cloudflare/workerd#8476); the saving is the
macrotasks that are skipped, whatever each one costs. The e2e test's
name now says it covers both chain lengths.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
The fulfilled Response was built without a statusText. workerd up to
1.20261012 filled in the status code's reason phrase; 1.20261123.1
follows the Fetch spec and leaves it empty. A fulfilled 422 then had
an empty statusText, which broke Playwright's "should work with
status code 422". Playwright and Puppeteer both send responsePhrase.

The phrase is now passed through to the Response and to the Network
events. A phrase that is not a valid reason-phrase is rejected with
Chrome's "Invalid http status code or phrase" error, not with a
TypeError when the request is fulfilled.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
…asses

"should fulfill with unuassigned status codes" expects the "Unknown"
phrase that Playwright sends for status 599. It passes now that
Fetch.fulfillRequest honors responsePhrase.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
…creenshot

Page.captureScreenshot checks for a PageScript, then awaits a resource
drain before it renders. A reload that starts during the drain unloads
that document, so the render failed with "no PageScript loaded" or
"recordScene rejected: PageScript: no document loaded". Chrome captures
whichever document is committed. This broke Playwright's "should take
fullPage screenshots during navigation" on workerd 1.20261123.1. The
race was there before; the new timing hits it in every run.

When the render fails and a navigation has started since the attempt
began, wait for the new document and capture it. Stop after three
attempts.

Adds an e2e test that fails without this change, also on the workerd
bump alone.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
Compression streams (brotli), TextDecoder arguments, Response bodies
from streams, Response.redirect and two WebCrypto tests now pass. They
passed in both CI runs on this branch.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
@ruifigueira
ruifigueira force-pushed the rfigueira/bump-workerd branch from 901470b to 87c2422 Compare November 26, 2026 14:45
Two cross-document assignments in one evaluate queue two navigation
reports. Both wait until the reply, so the evaluate still returns its
value. The case fails when the report goes back to a plain
nativeSetTimeout, as the single-assignment test does.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
@ruifigueira
ruifigueira merged commit b2e418d into main Nov 26, 2026
10 checks passed
ruifigueira added a commit that referenced this pull request Nov 27, 2026
WebMCP spec PR #245 moved ontoolactivated and ontoolcancel from window
to ModelContext, and the pinned IDL now has the ToolActivatedEvent and
ToolCancelEvent interfaces. The shim still sent plain Events to window,
so the WPT abort tests waited for events that never came.

Fire trusted ToolActivatedEvent and ToolCancelEvent at the tool's
ModelContext, and add the three event handler attributes. ModelContext
now uses the shared EventTarget, so listener options such as once and
signal work and the event's target is the context. A WebMCP.invokeTool
call fires the same events, and toolactivated fires even when execute()
throws synchronously, as WebIDL turns the throw into a rejection.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
ruifigueira added a commit that referenced this pull request Nov 27, 2026
WebMCP spec PR #245 moved ontoolactivated and ontoolcancel from window
to ModelContext, and the pinned IDL now has the ToolActivatedEvent and
ToolCancelEvent interfaces. The shim still sent plain Events to window,
so the WPT abort tests waited for events that never came.

Fire trusted ToolActivatedEvent and ToolCancelEvent at the tool's
ModelContext, and add the three event handler attributes. ModelContext
now uses the shared EventTarget, so listener options such as once and
signal work and the event's target is the context. A WebMCP.invokeTool
call fires the same events, and toolactivated fires even when execute()
throws synchronously, as WebIDL turns the throw into a rejection.

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for human review An independent agent reviewed this exact commit and found nothing blocking vouch:trusted Author is vouched, a collaborator, or a bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants