Repository navigation
fix(engine): a page can no longer grow the served-script record or the server log - #8854
miguel-heygen wants to merge 1 commit into
Conversation
…its log without end
Edit accuracy: accurate 273 (base branch 271), smooth 56 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) Unstable (1)
|
vanceingalls
left a comment
There was a problem hiding this comment.
Reviewed at f967657. No blocker in the code; approval follows green on one required check.
Checked:
- Cap count: the 10,000 distinct digests are kept, a repeat of a kept one is a no-op, and the 10,001st new one sets
tooManyServedScripts. No off-by-one. The set can never exceed 10,000 entries (28 chars each), so growth is bounded before the cap trips. - Failure is loud:
assertCaptureIntactthrowsTooManyServedScriptsErrorwith a message that names the limit, at all four points whereassertVfxIntactran (after page ready, before each frame, before each batch). It is not a silent truncation or a hang. - File server:
ENAMETOOLONGnow returns null fromopenRegularFile, so the request is a 404. The other path checks before it (isPathInsideviaexistsSync,realFilePathwith its catch-all) do not throw on a long name, so the outside-files mode is covered too. The 404 log cuts the URL path withboundedPageTextbeforeterminalTextescapes it, so it stays near 2,000 chars. The line logs only the request path, not an absolute path. - Tests: both are red on main and green here. The frameCapture test goes through the real
responselisteners and covers the 10,000/repeat/10,001st boundary for single-frame and batch capture. The fileServer test asserts 404 and the log line length. The PR body has thefails without the fix:line naming both tests.
Required check Tests on windows-latest is red at this head, from two timeouts in files this PR does not touch: videoFrameExtractor.supersetIsolation.test.ts ("Hook timed out in 10000ms", engine-cli-3) and cli/src/ui/renderDiagnostic.test.ts ("Test timed out in 20000ms", engine-cli-2). That looks like Windows runner slowness, not this change. Every other check finished green. I will approve once the Windows lanes are green on a rerun.
For the owners, not a blocker: 10,000 is far above a normal composition, but the count is by full URL including the query string. A composition that re-injects a script with a changing query (a cache-buster per frame) would now fail a long render instead of just growing memory. The limit value is the owners' call.
|
On the query string: yes, the cap counts each distinct full URL, query included, because that is the key the record already used. A throw's stack names the URL with its query, and the digest is looked up by that exact URL. So a composition that loads one script under a new query each time (a cache-buster per frame) adds one entry per load. Before this change that grew the record without end. Now a render stops at the 10,001st, which at 30 fps is about 5.5 minutes of one load per frame. A composition that loads each script once, or reloads the same URL, never comes near it. If that pattern should keep rendering, the record could key on the URL without its query. The server serves the same file for any query, so attribution would not change, and the count would then be bounded by the scripts the project actually has. That is a change to what the limit counts, so I am leaving it to the owners rather than folding it into this PR. |
vanceingalls
left a comment
There was a problem hiding this comment.
Approved at f967657. The two Windows timeouts (engine-cli-2/3, files this PR does not touch) passed on rerun; all checks are green. Earlier read stands: the cap counts correctly with no off-by-one, TooManyServedScriptsError names the limit, ENAMETOOLONG answers 404 with the path cut before logging, both tests are red on main. Open question for Vance (non-blocking): the cap counts full URLs including the query string.
What
Two places a rendered page could still grow what the render server keeps or logs:
Why
The render keeps a digest of every script URL the composition server answered, to tell a project script's throw from the document's. Each entry is a fixed 28 characters, but nothing capped how many there were: a page that fetches scripts under ever-new URLs grew the set for as long as the render ran. A count cap that simply stopped adding would let a throw from a later project script go unattributed, so the render stops instead. Under the cap every served script is still remembered, so attribution is unchanged.
A page can also ask the file server for a name longer than the file system allows.
openSyncthrows ENAMETOOLONG, whichopenRegularFiledid not treat as "no such file". Its fallbackstatSyncthrows the same error, so the request ended in a 500, and the server logged the page's whole path (10,000+ characters) with a stack trace on every such request.Related work
None open on these paths.
How
engine/pageTextBounds.ts:SERVED_SCRIPTS_MAX = 10_000, beside the other page bounds.engine/frameCapture.ts: theresponselistener adds a new script's digest only below the cap; a new script past it setstooManyServedScriptson the session.assertVfxIntactbecomesassertCaptureIntact, the one check that stops a session, and it now throwsTooManyServedScriptsErrortoo, at the same four points (after the page is ready and before each frame or batch).producer/fileServer.ts:openRegularFilereturns null for ENOENT, ENOTDIR and ENAMETOOLONG, so the server answers 404. The 404 warning cuts the request path withboundedPageText, now exported from the engine.Test plan
Unit tests added/updated
Manual testing performed
Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug
frameCapture.test.ts, "stops the render once the page loads more different scripts than a render tracks": through the real listeners, 10,000 distinct served scripts plus one repeat do not stop capture; the 10,001st does, for both single-frame and batch capture.fileServer.test.ts, "answers a name too long for the file system with 404 and logs it cut short": a request for a 10,000-character.pngname gets 404, and no log line is over 2,100 characters.fails without the fix: on main 4c0d614, the first test fails because capture carries on past the 10,001st script (it reaches the stand-in page instead of stopping), and the second fails with 500 instead of 404. With the change, each passes 3 runs in a row.
frameCapture.test.tsandframeCapture-subTimelineMemo.test.ts, 84 passed, 3 runs in a row, including "records every served script's throw, however many and long". The whole engine suite: 3,763 passed; the 4 failures are inffprobe.test.ts, whose HDR PNG fixture was not fetched from LFS in that checkout.fileServer*.test.tsfile under its own runner (bun or vitest), 139 passed.tsc --noEmitclean for engine and producer; oxlint, oxfmt, the comment ratchet and the commit hooks are green.