viewer: say the world file could not be read when the body read fails, not that the JSON is invalid (WORLD-JSON-READ-MISREPORTED) #918
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/918"
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 TuroYT on 2026-11-24T15:11:32Z.
Claimed in the coordination issue as: WORLD-JSON-READ-MISREPORTED (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135526454)
What was wrong
viewer/index.html,loadWorld()(line 119 before this change):world = await response.json();ran inside the same try as the fetch. The catch chose its message fromresponse, which is set once the fetch has returned. So when the status was 200 and the body read failed (for example a dropped connection), the viewer saidworld/world.json could not be read as valid JSON.The file may be valid, and the failure was the network.Reproduction on
main(a28927849), with a stubbed fetch and the function read from the file in memory:What changed
loadWorld()reads the body withresponse.text()and parses it withJSON.parseas two separate steps. Astagevariable records which step was running when the error was thrown.... could not be read.when the read failed,... could not be read as valid JSON.when the parse failed,... could not be loaded.when the fetch failed (unchanged),... download timed out.when the deadline fired (unchanged).json:now providetext:. The test sandbox gets the hostJSON, so parsed arrays compare as before.could not be read.and notvalid JSON; a valid body still loads.Overlap with open pull requests
loadChunkinviewer/index.htmland adds fixtures and tests after line 456 of the test file. This pull request does not touch those hunks. ItsloadWorldhunk is at lines 110-130, and its test hunks are at lines 21-22, 68-95 and 110.loadWorld.Tested
The new cases fail on the unfixed
viewer/index.html(themainversion, run with the new test file):The valid-body case also fails on the unfixed code, because its mock provides only
text()and the old code callsjson().Not tested: a real browser. The viewer was not served or opened, so no page load, console or network check was done. The change is inside
loadWorld(), which runs once at startup. No GPU, no game files.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-24T17:39:34Z.
Review: APPROVED
LGTM. Measured on Windows 11 with Node 26, against main
cf4c00cba:node --test tests/test_viewer_streaming.cjs: main 57/57; this PR and a local merge into main 59/59.stage === "read"line from this PR'sviewer/index.htmlturns the new read-failure test red (58 pass, 1 fail). The body-stall test now mockstext(), so the deadline still covers the read.vmharness.AI-assisted: yes (Claude Code ran the checks; I read them).
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T21:46:29Z.
#918 | head
23b70597de(merged cleanly with maina8465211fb) |node --test tests/test_viewer_streaming.cjs| red on main:fail 25 / 59(viewer/index.htmlcalledawait response.json()directly and caught every post-fetcherror with"world/world.json could not be read as valid JSON.", misreporting mid-body HTTP 200 read drops as JSON syntax errors) | green on PR+main:pass 59 / 59, fail 0(duration_ms 282.6) | Windows 11 (10.0.26200.9974), Node.js v24.16.0 | AI-assisted: yesAudited
viewer/index.htmlandtests/test_viewer_streaming.cjson Windows 11: trackingstage = "fetch" | "read" | "parse"acrossfetch,response.text(), andJSON.parse(text)cleanly separates body-stream read failures ("world/world.json could not be read.") from malformed JSON ("world/world.json could not be read as valid JSON.") while preserving theAbortControllertimeout path. Also verifiedtests/test_ci_registration.pyandscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:58:20Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Node v26.7.0, main
59e65849b, PR head23b70597d: red 25 failures / green 59 OKnode --test tests/test_viewer_streaming.cjs:a valid manifest is used, including an intentionally empty worldmalformed manifests keep the viewer usable and identify the invalid field (12 subtests)a body read that fails after a 200 response is reported as a read failure, not as invalid JSONa valid manifest body still loads after the read and parse are splita stalled world manifest falls back to generated terrain at the startup deadlinemanifest success clears the deadline and explicit test mode never schedules itthe bounds overlay creates helpers on the first G press and reuses themShift speeds the camera up and Ctrl slows it downmanifest chunks with test metadata still load their GLBa valid LOD manifest is acceptednode --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:15:51Z.
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
main21bdf6b60without 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.