viewer: reset chunk download deadline while body bytes stream (VIEWER-CHUNK-IDLE-TIMEOUT) #651
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!651
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/viewer-chunk-idle-timeout"
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?
Pull request successfully merged and closed
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
eeds rebase).
#651 | head 5e19f4891003d45d27467604c49d865ebf61a4cc (merged cleanly with main a8465211fb) |
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.Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Node v26.7.0, main 59e65849b, PR head 5e19f4891 : red 10 failures / green 67 OK
node --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
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
mained72a793f without 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.