Repository navigation
fix(studio): a failed preview reload logs whether the project or our code threw - #8920
miguel-heygen wants to merge 4 commits into
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 0b9ba5b, by reading (no test run on my box). I read useShadowPreviewReload.ts around the change, the server script that records the kinds, and both new tests.
No blocker. What I checked:
- The people-facing message.
messageis built as before and handed toonReloadFailedunchanged; only the console line gets the tail. The first test asserts both. - Reading the frame.
firstErrorFromreturns nothing whencontentDocumentis null (another site's page, a detached frame), so the window is never touched where reading it would throw. A sealed frame is skipped by the same guardgotuses. The read happens before the shadow is stopped and dropped. - Where the words come from. The server's early-errors script pushes one of
unknown,runtime,project,studioper error, from the throwing script's path on the page's own origin. The reader takes entry 0. - Fix rule. The
fails without the fix:line names the first new test inuseTimelinePlayer.shadowReload.test.ts; it is at this head and pins the tail at the end of the line.
Notes, not blocking:
- The array is an ordinary property of the page's window, so a project's own script can write to it. The reader accepts any string there. If the host is going to copy this word into a line it otherwise strips, either accept only the four words here (one small set check) or have the host match on them. Worth saying which in the follow-up.
- "First" is the first error since the page loaded, not the one that broke the reload. A harmless early project error followed by a runtime failure reads as
project. The line says "first page error", so it is honest, but whoever reads the tracker should know. - The test comment names one host and one vendor; the PR body says "a host" and "its error tracker". Matching the body would read better here.
Need: yes, failed reloads cannot be told apart by source today · Size: +59, 18 in source · Reuse: the kinds the server already records, the existing sealed guard · Simpler: no · Structure: one reader beside pageGotTo
Risk: low. Console text only, no change to reload or retry behaviour.
— Rames
No visible changeNothing on screen changes: the only new output is the end of a console line when a preview reload fails. The message Review notes
Also at 22e3ada: the reader's doc comment is gone, since the comment ratchet only lets a file's comment share go down. Its name and |
Edit accuracy: accurate 273 (base branch 271), smooth 60 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
What
When a preview reload fails, Studio's console line now ends with where the page's first script error came from:
Its first page error came from: project.(orruntime,studio,unknown). The message handed toonReloadFailed, which a host may show to people, is unchanged.Why
A host that forwards console errors to its error tracker has to strip the error's own text, since it is the project's content. What is left is only the error's class, for example "the preview reload hit a TypeError". That reads the same whether the project's own script threw (often an agent halfway through an edit) or the HyperFrames runtime or Studio did, so whoever is on call cannot tell a project's broken script from a bug of ours without digging through sessions by hand.
studio-server's early-errors script already records a closed origin for every error the page raises (
window.__hfPreviewErrorKinds, one{ name, origin }per error, origin from the throwing script's path). Nothing read it when a reload failed.How
failShadowalready holds the failed reload's iframe when it builds the message. A newfirstErrorFrom(iframe)reads the first recorded origin from that page and the console line appends it. It reads nothing from a sealed frame (the same guardgotuses) or a page whose document it cannot read, and adds nothing when the page recorded no error. The value stays a closed word; the error's text is never added.Test plan
Two tests in
useTimelinePlayer.shadowReload.test.ts: a page that recorded a project error and then a runtime error logscame from: projectat the end of the console line, andonReloadFailedgets the message without it; a page that recorded no error logs no origin.fails without the fix: with
${errorFrom}removed from the console line, the first test fails and the other 65 in the file pass.With the fix: the file passes 3 runs in a row (66 tests), and all 27 files under
src/player/hookspass (293 tests) on a Linux devbox.tsc --noEmitfor studio,oxlint,oxfmt, and the commit hook'sfallowand typecheck: clean.Not exercised: a real reload failing in a running Studio. Next, the host maps this word into its redacted line; that change lives in the host.
Unit tests added/updated
Manual testing performed
Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments"