viewer: reset chunk download deadline while body bytes stream (VIEWER-CHUNK-IDLE-TIMEOUT) #651
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/651"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-24T10:59:07Z.
Claimed in the coordination issue as: VIEWER-CHUNK-IDLE-TIMEOUT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129434586)
What and why
Follows up on @slauko's finding in #14 (comment 7128949696), where valid multi-hundred-megabyte clay chunks (up to 773 MB) hit
CHUNK_DOWNLOAD_TIMEOUT_MS(30 s) on a cold read because the timer bounded the entire download wall-clock duration rather than idle stalls.viewer/index.html: addparseContentLength/readChunkBytessoloadChunkstreams chunks viaresponse.body.getReader()and resets the 30 s deadline whenever non-empty body bytes arrive:Uint8Array(capped at 1 GiB) when an uncompressedContent-Lengthis valid, spilling gracefully if more bytes arrive or slicing if the stream ends early; omits preallocation whenContent-Encodingis set.AbortSignalabort and releases the lock infinally.response.arrayBuffer()whenresponse.body?.getReaderis absent.tests/test_viewer_streaming.cjs: extend the mockfetch/GLTFLoaderfixture withstreamHeadersandparsesand add 5 unit test groups covering sliding idle timeouts (with and withoutContent-Length), headers-only stalls, empty-chunk stalls,Content-Lengthmismatches /Content-Encoding, and mid-transfer cancellation/drop cleanup.Tested
On Windows 11 x64 (Node v24.19.0, Python 3.14.7) at $sha, synthetic fixtures only (no game data):
node --test tests/test_viewer_streaming.cjs— 67 passed, 0 failed (includes 5 new streamed-timeout / assembly tests)node --test tests/test_viewer_studio.cjs— 11 passed, 0 failedpython -I tests/test_viewer_cdn_integrity.py— 10 ran, OKpython -I tests/test_viewer_serve.py— 39 ran, OK (1 skipped)python -I tests/test_ci_registration.py— 15 ran, OKpython -I tests/test_text_write_line_endings.py— 3 ran, OKpython -I tests/test_check_no_game_data.py&python -I scripts/check_no_game_data.py— exit 0python -m compileall -q make_game.py tools tests— exit 0GPUs tested: n/a
AI-assisted: yes
Checklist
21625bca) and merges cleanly (a conflicting pull request is labeledeeds rebase).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-24T11:27:35Z.
Review: COMMENTED
Independent verification at
5e19f489: all 67 viewer streaming tests and 11 viewer studio tests passed. I also exercised the downloader over loopback HTTP with a shortened deadline and synthetic bytes. With nonempty body fragments arriving within each idle interval but taking longer than one interval in total, the base aborted and the PR returned the complete byte sequence. Both revisions still aborted a stalled response.AI-assisted testing.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:01:48Z.
#651 | head
5e19f48910(merged cleanly with maina8465211fb) |node --test tests/test_viewer_streaming.cjs| red on main:pass 57, fail 10(loadChunkset a singleCHUNK_DOWNLOAD_TIMEOUT_MStimer acrossfetch+response.arrayBuffer()without resetting on streaming progress, aborting active multi-chunk transfers after 30 s) | green on PR+main:pass 67 / 67, fail 0(duration_ms 284.5) | Windows 11 (10.0.26200.9974), Node.js v24.16.0 | AI-assisted: yesAudited
viewer/index.htmlandtests/test_viewer_streaming.cjson Windows 11:readChunkBytesresets the idle deadline only on non-empty body chunks (never on headers alone or zero-byte chunks), handlesContent-Lengthmismatches andContent-Encodingbodies safely (MAX_PREALLOC_BYTEScap), and cancels/releases theReadableStreamreader lock on timeout ordrop(). Note: touchesviewer/index.htmlandtests/test_viewer_streaming.cjsin disjoint sections from#918(loadWorldvsloadChunk). Also verifiedtests/test_ci_registration.pyandscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:58:22Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Node v26.7.0, main
59e65849b, PR head5e19f4891: red 10 failures / green 67 OKnode --test tests/test_viewer_streaming.cjs:streamed chunk downloads reset the idle deadline on each non-empty body chunk (with and without Content-Length)streamed chunk headers alone do not reset the download deadlineempty body chunks do not reset the streamed download deadlinestreamed chunk assembly handles Content-Length mismatches and encoded bodies (3 subtests)dropping a streamed chunk mid-transfer cancels its reader and releases the locknode --test tests/test_*.cjs).git merge --no-ffonto main). The PR's test file is not older than main's, so the red run is the plain one.Verdict: READY
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T02:16:05Z.
Merged after OreoFR's red/green check (check) (macOS 27.2.1, Apple M5) and a local re-check here. Merged after local re-verification: this PR merged onto
mained72a793fwithout conflict, and its test file(s) (tests/test_viewer_streaming.cjs) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.