Repository navigation
feat(studio-server): the preview records the kind and origin of each early error - #7041
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Approve at 5173140f. No blockers.
- Privacy:
kindsonly ever holds one of four fixed built-in names or"other", plus one of four fixed origin labels. Neither the message nor the file path is copied in.known[name]===1also stops inherited keys such astoStringfrom getting through. The test checks that no"secret"text leaks. - Origin: the runtime path comes from
adapter.runtimeUrl, which is/api/runtime.jsin both the CLI and Vite adapters, so it isn't hard-coded. A URL is only classified when it is same-origin, so a cross-origin "Script error." or a CDN library comes out asunknown. The composition's inline scripts report the page URL, which is under/api/projects/, so they come out asproject. - Compatibility: the
__hfPreviewErrorstext array is pushed to exactly as before. The new array is added alongside it, in the same order. - Fix-line rule: the "fails without the fix:" line names
preview.test.ts › records the kind and origin of each early error…, and that test reads__hfPreviewErrorKinds, which doesn't exist on main.
Non-blocking: the /api/projects/ prefix is a literal, while the runtime path comes from the adapter. If a host ever mounts the API under a different prefix, project errors would be labelled studio. Deriving the prefix the same way would keep the two consistent.
Contributor
miguel-heygen
enabled auto-merge
November 2, 2026 22:34
miguel-heygen
force-pushed
the
feat/preview-error-kinds
branch
from
November 3, 2026 00:07
5173140 to
2bab77d
Compare
miguel-heygen
force-pushed
the
feat/preview-error-kinds
branch
from
November 3, 2026 02:57
2bab77d to
de1116a
Compare
Contributor
There was a problem hiding this comment.
Approve at a745dab7. No blockers.
Delta since 5173140f (my earlier approval): a rebase onto main plus one commit for the code-scanning finding.
scriptJson: it isJSON.stringifywith<, U+2028 and U+2029 escaped. That stops a value from closing the tag with</script>, opening<!--, or breaking the line in older engines. It is applied in both places that inline a value: the runtime path in the early-errors script, andcdnBasein the GSAP fallback.cdnBasealready escaped<, so its only new behaviour is the line-separator escaping. TheJSON.parseround-trip in the new test shows the value itself is unchanged.- Feature unchanged: the rest of the early-errors script is byte-for-byte the same as what I reviewed before. The fix line still names the kinds test, which fails on main.
- CI so far:
regressionfailed at "Set up Docker Buildx" in shard-1, which is an infrastructure step and not this change.preview-regressionand PR captures passed, and CI and CodeQL are still running.
Merged
1 task done
Merged
2 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
The Studio preview already keeps every error raised before the player attaches, as text, in
window.__hfPreviewErrors. It now also pushes one{ name, origin }object per error into a second array,window.__hfPreviewErrorKinds, in the same order. The text array is unchanged.nameis the error's constructor name when it isSyntaxError,TypeError,ReferenceErrororRangeError, andotherfor anything else (including an error with no error object).originis where the failing script came from, read from the error'sfilename:runtime: the preview runtime script (/api/runtime.js),project: a page or file under/api/projects/, which covers the composition's own inline scripts and its project files,studio: any other script served by the same server,unknown: no filename (for example a cross-origin "Script error."), or one that is not on this server.The new array carries no message text, so a host that embeds the preview can tell what kind of error it was and where it came from without reading anything the author wrote.
Why
A host that embeds the preview only had the message text, which is free-form and can contain authored content. A fixed name and origin is enough to tell a bug in the runtime from a bug in the project, and it can be reported safely.
No visible change
Nothing on screen changes. No Studio or player file is touched; the preview page gains one inline array that only code reads.
Tests
preview.test.tsruns the injected script against a fake window and raises five errors: one from the runtime, one from a project file, one from another script on the server with a custom error class, one from another site, and one with no filename. It expects the exact{ name, origin }list, the message array unchanged, and no error text anywhere in the new array. 150 tests pass in the file, 3 runs in a row.fails without the fix:
preview.test.ts › records the kind and origin of each early error, never its text, and leaves the messages as they werefails on main, where the array does not exist.Size
62 changed lines: one constant, one inline script and its test.