Skip to content

test(tanstackstart): Deterministically match the server-side error event#22137

Open
mydea wants to merge 1 commit into
developfrom
test/tanstack-e2e-select-server-error-event
Open

test(tanstackstart): Deterministically match the server-side error event#22137
mydea wants to merge 1 commit into
developfrom
test/tanstack-e2e-select-server-error-event

Conversation

@mydea

@mydea mydea commented Jul 9, 2026

Copy link
Copy Markdown
Member

The tanstackstart server-function error test flaked: it asserted the error's mechanism is auto.middleware.tanstackstart.server_function, but occasionally received auto.browser.global_handlers.onunhandledrejection instead.

Root cause: the thrown error propagates back to the client over the server-function RPC and is captured a second time on the client as an onunhandledrejection with the same message. The waitForError predicate matched on message only, so it raced the two events and sometimes resolved with the client-side duplicate.

The predicate now also matches the server mechanism, so the correct server-side event is always selected. The same latent race exists in the API-route test (identical message-only predicate + specific-mechanism assertion), so that predicate is hardened the same way.

Fixes #21912

🤖 Generated with Claude Code

The server-function and API-route error tests waited for the error event by
message only. But the thrown error also propagates back to the client (over the
server-function RPC / fetch) and is captured there as an
`onunhandledrejection` with the same message, so `waitForError` raced the two
and sometimes resolved with the client-side duplicate — failing the mechanism
assertion (`auto.browser.global_handlers.onunhandledrejection` instead of the
expected server mechanism).

Match the server mechanism in the predicate so the correct server-side event is
always selected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea mydea marked this pull request as ready for review July 9, 2026 11:05

@isaacs isaacs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❄️🚫 love too see it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants