Skip to content

fix(bench): install Text, Comment, and CharacterData in strong-compiler-checks DOM shim - #1490

Merged
trueadm merged 1 commit into
mainfrom
claude/mystifying-rubin-3a55eb
Oct 1, 2026
Merged

trueadm merged 1 commit into
mainfrom
claude/mystifying-rubin-3a55eb

Conversation

@trueadm

@trueadm trueadm commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

benchmarks/strong-compiler-checks/run.mjs fails on current main in its cached-semantics control with ReferenceError: Text is not defined, thrown from the runtime's bindSignalText. Every run, including --smoke, recorded status: "failed".

validateCachedSemantics copies a fixed list of happy-dom constructors onto globalThis before it runs each revision's bundled runtime. The text-binding path now uses previous instanceof Text with no guard, and Text was not on that list.

This adds three names to the list:

  • Text fixes the failure.
  • Comment: the runtime doesn't need it today, because it only appears in type positions (node is Comment). It's the other CharacterData node kind the runtime works with, so adding it means a future instanceof Comment can't break the harness the same way.
  • CharacterData: its absence didn't throw, because initDomOperations checks typeof CharacterData first. But without it the harness skipped the Text/Comment expando seeding that every browser does. With it installed, the check exercises the same code a browser does.

Audit of other DOM globals

I searched packages/octane/src for instanceof X, new X, X.prototype, X.CONST, and bare browser functions. Nothing else on the load or mount path is missing:

  • Node, Element, HTMLElement and Event are used without guards, and the harness already installs them.
  • IntersectionObserver, requestAnimationFrame, CSS and MessageChannel are all guarded with typeof checks.
  • MessageChannel stays installed as undefined on purpose. happy-dom has none, so this hides Node's version and puts the runtime on its timer fallback, as the existing harness comment says.
  • FormData and DOMException fall back to Node's own globals. Only form actions and RPC code reach them, and this workload doesn't.

I kept the fixed list instead of copying every constructor from the window. esbuild.build runs while the globals are installed, and replacing Node's own URL, Blob, TextEncoder and similar globals in that process would be riskier than the problem being fixed.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test: not run. Nothing outside benchmarks/strong-compiler-checks/ references this harness, and it is not a registered CI suite. Its README says it runs directly because it needs an external baseline.
  • targeted: smoke run against a git archive snapshot of 874ca5f13 (current main), with the snapshot's root and packages/octane node_modules symlinked to the worktree's install:
    node benchmarks/strong-compiler-checks/run.mjs --smoke --baseline <snapshot> \
      --baseline-revision 874ca5f139c6ed6f29b4970a567bc7e22b0b3ca4 --output <tmp>/out.json
    • Before: status: "failed", with ReferenceError: Text is not defined.
    • After: status: "complete", with 28 targets and the sourcesStable record present. All 8 lane/policy controls ran: each has 8 observations, and the client lanes each have 6 cache-identity records (server lanes have 0, as expected).
  • full paired run against main: completes, with all controls passing; see below.
  • pnpm sync produced no generated changes.

Smoke timings are one sample each and aren't performance evidence; the harness README says the same. The full paired run against main is reported below.

Full paired run against main

Both sides compile byte-identical packages/octane/src: main is 874ca5f13, and both aggregate source SHA-256s are 85ce03d8…. So this run proves the full harness completes and shows its noise on identical code. It is not a performance comparison.

node benchmarks/strong-compiler-checks/run.mjs --baseline <snapshot of 874ca5f13> \
  --baseline-revision 874ca5f139c6ed6f29b4970a567bc7e22b0b3ca4 --output <tmp>/full.json
  • Result: status: "complete", with 56 targets. Sources and dependency resolutions stayed stable, all 8 cached-semantics controls passed, and emitted output is byte-identical between the two sides in all 28 cases.
  • Environment: Node v24.18.0 (V8 13.6.233.17), Apple M5 Max, darwin 27.0.0 arm64. Default settings: 3 warmup pairs, then 17 measured pairs at 100 functions and 11 at 1,000. Ran 2026-10-01, 08:47–08:54 UTC.

Paired median ratios (candidate ÷ baseline; 1.0 is the ideal for identical code):

Workload / lane Strong, 100 Strong, 1,000 Compat, 100 Compat, 1,000
normal / prod-client 1.003 0.966 0.980 0.989
ambient / prod-client 0.996 1.000 1.000 0.994
alias-heavy / prod-client 0.995 1.016 0.987 0.972
cached / prod-client 1.017 1.001 0.982 1.007
cached / dev-hmr 1.009 1.025 0.992 0.984
cached / server 0.998 0.994 0.996 1.002
cached / plain 1.074 1.048 ⚠ 1.022 0.997 ⚠

The ratios run from 0.966 to 1.074, with a median of 0.998. On this machine under these conditions, a difference of up to about 7% is noise, and the 100-function plain lane is the noisiest.

The conditions were not clean:

  • The machine was on battery for the whole run, with a load average of 4–7. Absolute times are about 1.3–1.6× the README's 14 September figures, which also used Node v26.4.0, so the millisecond columns can't be compared with that table.
  • ⚠ The lid closed at 08:51:58 UTC. pmset -g log shows a 172 s clamshell sleep and a DarkWake at 08:54:50.
    • One Strong cached/plain 1,000-function candidate sample measured 169,780 ms; its neighbours were 225 ms and 202 ms.
    • The final three Compat cached/plain 1,000-function samples ran at about 500 ms instead of about 100 ms, on both sides.
    • The paired medians absorb both, but the p95 and min/max figures for those two cases are meaningless.
  • The Compat cached/prod-client 1,000-function case had three early outliers from background load, up to 1,868 ms against a typical ~480 ms. Its paired median is 1.007.

The raw JSON is not committed, because it measures noise rather than a change.

Risk / follow-ups

  • This only changes the harness's DOM shim. The new harnessSha256 will differ from the one in results-2026-09-14.json, which is expected for any harness edit.
  • No changeset: this is internal benchmark tooling, not a published package.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Only internal benchmark harness DOM globals change; no compiler or runtime code is modified.

Overview
Fixes the strong-compiler-checks harness so its happy-dom DOM shim matches what the bundled runtime expects during the cached-semantics control.

validateCachedSemantics now copies CharacterData, Text, and Comment onto globalThis alongside the existing window/DOM constructors. Text is required because signal text binding uses unguarded instanceof Text; without it the harness failed with ReferenceError: Text is not defined. CharacterData enables the same expando seeding path browsers hit at init; Comment preempts a similar gap if the runtime ever checks instanceof Comment.

Reviewed by Cursor Bugbot for commit 9d11f41. Bugbot is set up for automated code reviews on this repo. Configure here.

…er-checks DOM shim

validateCachedSemantics installs a fixed list of happy-dom constructors on
globalThis before executing each revision's bundled runtime. The runtime's
text-binding path now does an unguarded `previous instanceof Text`, so the
cached-semantics control failed with `ReferenceError: Text is not defined`
and every run (including --smoke) recorded status "failed".

Add Text, plus Comment (its sibling CharacterData node kind, so a future
value-position reference does not break the harness the same way) and
CharacterData. CharacterData is typeof-guarded in initDomOperations, so its
absence did not throw, but it made the harness skip the Text/Comment expando
seeding that every browser performs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 1, 2026
@github-actions
github-actions Bot marked this pull request as draft October 1, 2026 08:37
@trueadm
trueadm marked this pull request as ready for review October 1, 2026 09:27
@trueadm
trueadm merged commit 2852d14 into main Oct 1, 2026
57 checks passed
@trueadm
trueadm deleted the claude/mystifying-rubin-3a55eb branch October 1, 2026 12:02
trueadm added a commit that referenced this pull request Oct 1, 2026
Brings in #1496 (stale deferred state updates), #1498 (uncached
useSyncExternalStore snapshots), and #1490. Keeps both new compiler imports in
strong-mode.js.

The workaround ledger records that #1498 now rejects the fresh-snapshot
viewport workaround (23 → 22 compiler gaps). Prompts, references, and
alternatives are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant