Skip to content

test(pds): call the worker directly instead of the loopback; fix(spaces): attestation fetches on workerd - #258

Merged
ascorbic merged 5 commits into
mainfrom
pds-conformance-timeout
Nov 21, 2026
Merged

ascorbic merged 5 commits into
mainfrom
pds-conformance-timeout

Conversation

@ascorbic

@ascorbic ascorbic commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

The PDS conformance test timed out on the release PR (#227). It had passed in 58.7s against a 60s limit on #257. Fixing that exposed a real bug in client attestation, which is fixed here too.

1. Test helper: the loopback made the suite quadratic

test/helpers.ts sent every request through exports.default.fetch, a loopback into the worker's own entrypoint. Each loopback call left every later one slower:

Path First requests After 1000 requests
exports.default.fetch, trivial 404 1.3ms 189ms
app.fetch called directly 0.4ms 0.1ms

The cause is in @cloudflare/vitest-pool-workers@0.16.9. Its createProxyPrototypeClass wraps the entrypoint wrapper's shared prototype in a new Proxy on every construction, so the traps stack up and every method lookup walks all of them. In Node, a lookup costs 0.7µs after one construction and 17ms after 1000. The fix landed in the renamed @cloudflare/vitest-plugin in 1.2.0, which installs the proxy once; the old package is deprecated and its final release (0.23.0) still has the bug. Moving to @cloudflare/vitest-plugin is left for a separate PR.

The conformance run makes about 1000 requests, so it took about 3s alone, about 25s after the other files, and about 60s on CI.

Fix: worker.fetch(request, env) now calls the Hono app directly, with a fresh ExecutionContext for each request. waitUntil work is left running, as in production. The signature is unchanged and the conformance timeout stays at 60s.

2. Attestation fetches used redirect: "error", which workerd refuses

Calling the app directly made the test pool report this as an unhandled rejection, and that failed the first CI run of this PR.

verifyClientAttestation fetched client metadata and JWKS with redirect: "error". workerd refuses that value outright: "won't be implemented … use "manual"". So on a deployed Worker every attestation failed, and a memberspace with allowedApps refused every app, attested or not. Nothing caught it:

  • the routes test's stub fetch ignored the option;
  • the conformance checks only cover refusals.

Fix: use redirect: "manual". A 3xx fails the existing ok check, so redirects are still refused. The stub now rejects "error" as workerd does, and a test pins workerd's behaviour through the Request constructor. With the fix reverted, the allowedApps attestation test fails. There's a changeset for @getcirrus/spaces (patch).

Results

  • PDS: 355 unit and 128 CLI tests pass, with no unhandled errors. The suite's test time drops from about 60s to 14.5s locally, and the conformance run from 25.4s to 3.0s.
  • spaces: 81 tests pass, with no unhandled errors.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB

It takes ~10s alone but ~25s after the rest of the suite in the shared
isolate, and CI is slower again: it passed in 58.7s against the 60s
limit on #257 and timed out on the release PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB
Every call through exports.default.fetch left the next one slower: 1000
requests took a trivial 404 from ~1ms to ~190ms, and the slowdown
carried across test files. Calling the Hono app directly shows no
growth. The suite was quadratic in requests made: the conformance run
(~1000 requests) took ~3s alone, ~25s after the other files, and ~60s
on CI, where it timed out on the release PR.

The helper now calls app.fetch with a fresh ExecutionContext per request,
leaving waitUntil work running as in production. All 355 tests pass,
and the run's test time drops from ~60s to ~15s locally. The conformance
timeout goes back to 60s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB
@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/create-pds@258
npm i https://pkg.pr.new/@getcirrus/oauth-provider@258
npm i https://pkg.pr.new/@getcirrus/pds@258
npm i https://pkg.pr.new/@getcirrus/spaces@258

commit: 9912642

@ascorbic ascorbic changed the title test(pds): give the conformance run 180s test(pds): call the worker directly instead of through the exports.default loopback Nov 20, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
cirrusdocs 9912642 Commit Preview URL

Branch Preview URL
Nov 21 2026, 11:58 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
pdscheck 9912642 Nov 21 2026, 11:58 AM

workerd refuses redirect: "error", so on a Worker every client metadata
and JWKS fetch threw, every attestation failed and a memberspace with
allowedApps refused every app. The unit tests' stub fetch ignored the
option, and the conformance checks only cover refusals.

Use "manual": a 3xx fails the existing ok check, so redirects are still
refused. The stub now rejects "error" as workerd does, and a test pins
that behaviour (via the Request constructor, which applies the same
check without a rejected promise for the pool to report twice).

Calling the PDS directly in tests (previous commit) surfaced this as an
unhandled rejection that failed the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZ7qcQNQoiA6a23woGC7tB
@ascorbic ascorbic changed the title test(pds): call the worker directly instead of through the exports.default loopback test(pds): call the worker directly instead of the loopback; fix(spaces): attestation fetches on workerd Nov 21, 2026
@ascorbic
ascorbic enabled auto-merge (squash) November 21, 2026 11:58
@ascorbic
ascorbic merged commit 9d5a282 into main Nov 21, 2026
6 checks passed
@ascorbic
ascorbic deleted the pds-conformance-timeout branch November 21, 2026 11:59
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.

2 participants