Skip to content

test(Tokenizer): the SSR test asserts no console error instead of muting it - #8766

Merged
cixzhang merged 3 commits into
meta:mainfrom
vjeux:uikit/c06-tokenizer-ssr-console
Oct 28, 2026
Merged

cixzhang merged 3 commits into
meta:mainfrom
vjeux:uikit/c06-tokenizer-ssr-console

Conversation

@vjeux

@vjeux vjeux commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Follows #8760 (merged). Review only this PR's change: vjeux/astryx@ad19aec...2e04bc8

Maintainer impact

Tokenizer.ssr.test.tsx mutes console.error and checks only React's recoverable errors. React reports some hydration mismatches only on the console: an attribute whose server value differs from the client's, for one. So a hydration that leaves a wrong attribute on the page passes this test. Nothing is logged today, so the mute hides nothing yet; it would hide the next such mismatch.

What led here: while fixing this file's timeouts in #8760, I saw the mute; #8685 had already found and replaced the same mute in DropdownMenu's SSR test.

Intended invariant

A hydration the test calls clean logs no console error.

Change

Options weighed:

  • Keep the mute and rely on recoverable errors: misses the mismatches React only logs.
  • Assert that one known message is absent: passes when React words a mismatch differently or reports a new kind.
  • Watch console.error without muting it and assert each hydration logs nothing. Chosen: it catches every logged error, and it is the shape test(DropdownMenu): the SSR test loads the menu and its sheet at collection #8685 uses, so the two SSR tests read the same.

Evidence

How to check: in serverRenderThenHydrate, tamper the server markup with html.replace('aria-expanded="false"', 'aria-expanded="true"') and run pnpm vitest run packages/core/src/Tokenizer/Tokenizer.ssr.test.tsx.

  • Failure before the change: main's file passes all three cases with the tampered markup (no recoverable error).
  • Success after the change: with the same tampering all three cases fail, naming React's attribute-mismatch error; without it, all three pass.
  • Product/runtime behavior verified unchanged: test-only.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • Tokenizer SSR tests: 3/3, logging no console error.
  • eslint, prettier, core typecheck.

vjeux added 3 commits October 27, 2026 15:10
…hes each case's sheet load

Each case hydrates a fresh module graph (`vi.resetModules()`, then an import
of Tokenizer's entry). The first case paid the graph's transform inside its
30 s budget, about 3.4 s alone and many times that on a busy machine, where
it timed out. Its work then kept running, and a coarse-pointer case's
on-demand sheet load resolved during the next case's hydration, which
reported "This root received an early update".

The entry and its sheet now load while the file is collected, which is
untimed, so each fresh graph only runs the modules again. A coarse-pointer
case finishes the sheet load its hydration starts before it unmounts, and a
case that ends early has its hydration finish before the next case starts.
…ing it

The hydration test silenced console.error and checked only React's
recoverable errors, but React reports some mismatches only on the console:
an attribute whose server value differs from the client's, for one. Nothing
is logged today (all three hydrations log no console error), so the mute
hid nothing yet; it would have hidden the next such mismatch. The test now
watches console.error without muting it and asserts each hydration logs
none.

Red first: with the server markup's aria-expanded tampered so it differs at
hydration, the muted test passed (no recoverable error) and this one fails
in all three cases, naming the console error.
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 28, 2026 12:18am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 28, 2026, 12:29 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 28, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks good to merge once CI finishes: watching console.error instead of muting it lets the Tokenizer SSR test catch hydration mismatches that React reports only on the console, the same shape DropdownMenu's SSR test uses. The tampered-markup check in the description holds up: with aria-expanded flipped in the server markup, the old test stays green and the new one fails all three cases on React's attribute-mismatch error. No changes are needed.

[Automated review]

@cixzhang
cixzhang merged commit 19d0a58 into meta:main Oct 28, 2026
61 checks passed
@vjeux
vjeux deleted the uikit/c06-tokenizer-ssr-console branch October 28, 2026 00:39

This branch was successfully deployed

1 active deployment
Preview — 2e04bc85 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants