Repository navigation
Conversation
|
Warning Review limit reached
On-demand reviews are free for the next 27 days. After that, they cost $0.25 per reviewed file. Or wait 26 minutes for your next included review. View limit detailsLimit details: You’ve used all 5 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
Comment |
There was a problem hiding this comment.
LGTM — test-harness-only change that swaps the CSS-load poll for load/error listeners and fixes Windows route separators.
Checked that stylesheetsSettled is assigned in loadPage after document.write but before the async HMR socket connects, so the console.info handler always reads the current page's promise; the empty-pending case resolves immediately and clears the diagnostic timer via .finally.
Checked settle is idempotent (repeated resolve()/Set.delete are no-ops), which the PR notes is needed because happy-dom 17 ignores {once: true}.
Checked the indexHtmlScript hoist: on POSIX path.sep === '/' so it's a no-op; on Windows both the import path and the route key now use /.
The new harness test targets 127.0.0.1:1 (local closed port), not external network.
Extended reasoning...
Overview
Test-infrastructure-only PR touching four files under test/bake/:
client-fixture.mjs: replaces a 20×50ms poll oflink.sheetwithload/errorlisteners attached right afterdocument.write, stored in a module-levelstylesheetsSettledpromise that the HMR-socket-connected handler awaits before acking. A 1s diagnostic timer names still-pending hrefs and is cleared in.finally.bake-harness.ts: hoistsreplaceAll(path.sep, '/')inindexHtmlScriptso the route key (not just the import path) uses forward slashes on Windows.dev/harness.test.ts: new case with a stylesheet link tohttp://127.0.0.1:1/...verifying the fixture settles on the error event and the failing link has nosheet.dev/css.test.ts: adds two assertions that a recovered page's HTML contains the bundled/_bun/asset/link and not the originalhref="styles.css".
No production/runtime code is touched.
Security risks
None. All changes are in the bake test harness and test files. The new test's "external" URL is 127.0.0.1:1, a local reserved port that refuses immediately — it does not contact the public internet.
Level of scrutiny
Low-to-medium. This is test tooling: a regression here surfaces as CI test failures, not user-facing bugs. The change is a net simplification (event-driven vs. polling) and the PR description documents the ordering guarantee (happy-dom starts link fetches after document.write returns), the dropped coverage (inline <style> and adoptedStyleSheets are synchronous in happy-dom; no bake test adds links from page scripts pre-socket), and why {once: true} isn't used. The author reports bun bd test test/bake/dev/ (134 tests) plus the sibling suites pass, and the four affected files pass on Windows x64.
Other factors
- I traced the reload path:
hardReload/location.reload→handleReload→createWindow→loadPagereassignsstylesheetsSettledbefore the new window's socket can connect, and the previous page's ack is generation-gated, so a stale promise resolving late is harmless. - The empty-
pendingcase (Promise.all([])) resolves on the next microtask and clears the diagnostic timer, so no spurious warning. - The
indexHtmlScriptchange is behaviour-preserving on POSIX (path.sep === '/') and only affects the multi-HTML branch's route keys on Windows. - No CODEOWNERS cover
test/bake/. No prior human review comments to address; only a CodeRabbit rate-limit notice.
…he client fixture The fixture polled link.sheet every 50ms and gave up after 1s before it acked a page load. A link whose request fails never gets a sheet, so every such page paid the full second. Listeners attached right after document.write see the load or error event of each link instead. indexHtmlScript built the route key of a nested HTML file from path.relative output, so on Windows "html/index.html" became the route "/html\index" and a client for "/html" got a 404.
|
Updated 9:39 AM PT - Aug 24th, 2026
❌ @robobun, your commit dca3273 has 2 failures in
🧪 To try this PR locally: bunx bun-pr 40357That installs a local version of the PR into your bun-40357 --bun |
e336ae6 to
dca3273
Compare
|
The first push carried a stray 5-line hunk in |
There was a problem hiding this comment.
LGTM — test-harness-only change that replaces a 1 s poll with event-driven stylesheet settling and fixes Windows route separators.
Reviewed: the settleStylesheets ordering (set after document.write, before the async HMR socket connect can fire console.info), the empty-pending case (Promise.all([]).finally clears the diagnostic timer), and idempotent settle given happy-dom ignoring {once:true}. Checked indexHtmlScript — normalization now covers the route key as well as the import path, so the later .replace("/index", "") chain works on Windows. The new test's 127.0.0.1:1 link is loopback-to-fail, not external network.
Extended reasoning...
Overview
Three files under test/bake/, all test infrastructure — no production/runtime code touched:
client-fixture.mjs: replaces a 50 ms poll (max 20 attempts = 1 s) forlink.sheetwithload/errorevent listeners attached right afterdocument.write. A module-levelstylesheetsSettledpromise is awaited when the HMR socket connect message arrives. The diagnostic 1 s warning is informational only; the harness's existing page-load timeout remains the failure path.bake-harness.ts: hoistsreplaceAll(path.sep, "/")inindexHtmlScriptso the route key is normalized too (previously only the import path was), fixing nested-HTML routes on Windows.dev/harness.test.ts: newdevTestwith one failing (127.0.0.1:1) and one succeeding stylesheet link, asserting[false, true]forlink.sheetpresence and exercising both initial load andhardReload().
Security risks
None. Test harness only; the new network reference is a loopback connect-refused, not an external host.
Level of scrutiny
Low-medium. Test-infrastructure change with no effect on the shipped binary. The main risk would be introducing flakiness into the bake suite, but the change moves from a time-based poll to awaiting the actual observable events, which is the direction the repo's test guidelines prescribe. The PR description reports 134 bake tests passing plus targeted Windows verification.
Other factors
- Ordering:
createWindow→loadPage(document.writethen assignstylesheetsSettled) → async script fetch → HMR socket connect →console.infohandler readsstylesheetsSettled. Same order onhandleReload. Initial value isPromise.resolve()so a stale read is harmless. - Dropped coverage of
<style>/adoptedStyleSheetsand script-injected links is explained in the PR notes (synchronous in happy-dom / no test uses them); acceptable for a fixture. settleis idempotent (re-resolveand re-deleteare no-ops), covering happy-dom's ignored{once:true}.- The diagnostic
setTimeoutis always cleared via.finally(), including the zero-pending case. - No prior human or bot review comments to address; CI build was in progress at review time.
|
CI on build #104954: 179 of 181 jobs pass, one canceled. The one failed job fails on |
Problem
test/bake/client-fixture.mjsacks a page load only after every<link rel="stylesheet">has asheet. It polledlink.sheetevery 50 ms and gave up after 1 s. happy-dom never gives a link whose request fails a sheet, so every such page paid the full second. A stale source tag after a failed CSS build (Dev server keeps the source <link rel="stylesheet"> tag after a failed CSS root recovers #40081) is one case, and in a project with several HTML routes it requests a path that 404s.indexHtmlScriptintest/bake/bake-harness.tsbuilt the route of a nested HTML file frompath.relativeoutput. On Windowshtml/index.htmlbecame the route/html\index, sodev.client("/html")got a 404.Fix
loadPageattachesloadanderrorlisteners to each stylesheet link right afterdocument.write. happy-dom starts the fetches afterdocument.writereturns and fires the events later, so no event is missed. The ack waits on that promise. A diagnostic warning names the links still pending after 1 s. The harness's own page load timeout stays the failure path./on every platform, as the import path already did.test/bake/dev/harness.test.ts, a page with a stylesheet link to a closed port. It takes 2.0 s here and 4.1 s with the old fixture, which logs two "Reached maximum CSS load check attempts" warnings.bun bd test test/bake/dev/passes with this fixture (134 tests, run together with the css.test.ts of test(bake): speed up dev/css.test.ts and tighten its assertions #40337), plustest/bake/{dev-and-prod,framework-router,deinitialization,serve-plugins-dev-server}.test.ts. Windows x64:test/bake/dev/{css,harness,html,hot}.test.tspass.Background
devTestspawns a dev server per case.dev.client(route)spawns a Node process that loads the page in happy-dom and acks over IPC once the HMR socket has connected and the stylesheets have settled. The harness waits for that ack before it returns the client.Notes
<style>elements andadoptedStyleSheetswere also checked by the old poll. Both are synchronous in happy-dom, so the new code only waits on<link>elements.{ once: true }onaddEventListener, so the settle callback is idempotent instead.indexHtmlScriptfix inside its consolidation. The second PR on top of this one, test(bake): speed up dev/css.test.ts and tighten its assertions #40337, reworkstest/bake/dev/css.test.tsinto multi-route projects and needs both changes here.[stamp-90s] gate passed · iteration 2 · 3 files touched
passes on PR (with fix)
diff hotspot
gate history · 1 passed · 1 rejected · iteration 2
evidence per changed file