Skip to content

Viewer: time out stalled startup manifests (TEST-858) - #3907

Open
olegmkrv wants to merge 1 commit into
ItsNotRexed:mainfrom
olegmkrv:viewer/manifest-startup-timeout
Open

olegmkrv wants to merge 1 commit into
ItsNotRexed:mainfrom
olegmkrv:viewer/manifest-startup-timeout

Conversation

@olegmkrv

Copy link
Copy Markdown

Claimed as TEST-858.

What and why

The viewer waits for world/world.json before starting. If the request stalls before the headers arrive or while the body is being read, the viewer never reaches its generated-terrain fallback.

Give the manifest request a 10-second deadline that covers both phases. On timeout, abort the download and show generated terrain with a timeout message. Keep the existing messages for missing, invalid, and unreachable manifests. Explicit test mode still skips the request. This is separate from the chunk-download timeout in #3795.

Tested

  • macOS, Node.js 23.6.0: all 51 tests passed in node --test tests/test_viewer_streaming.cjs. Both stall cases failed against the unfixed viewer.
  • With native Node fetch and a loopback HTTP server, verified that stalled headers and a partial body both trigger the generated-terrain fallback with a shortened test deadline.
  • git diff --check passed.

AI-assisted. No GPU, game data, keys, or decryption used.

@Atlonsky

Copy link
Copy Markdown

Viewer test at 2baf85b.

Environment: Windows 11 Pro 26200, Node.js v26.12.1 (CI pins 24 LTS; this is newer, in case that matters for timers).

  • node --test tests/test_viewer_streaming.cjs → tests 51, pass 51, fail 0, cancelled 0

The new stall cases (three attempts with increasing delays, stale parse retaining its slot, cancel-on-move) all pass, and the file's existing cases still pass.

@Hanioe2

Hanioe2 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Independent Windows verification of 2baf85b0 against parent aa2988cc on Windows 11 build 26200, Node.js 22.23.2.

  • node --test tests/test_viewer_streaming.cjs passed 51/51.

  • With native fetch and a local HTTP server, I held the headers in one run and sent an incomplete JSON body in another. I triggered the viewer's registered 10,000 ms deadline after confirming the request had reached the server (and headers had arrived in the body case). On the PR head, both paths showed generated terrain with the timeout reason, cleared the startup timer, and closed the unfinished response at the server. On the parent, both startup requests stayed pending until the test cleaned them up.

Only synthetic loopback inputs. AI-assisted.

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review of 2baf85b: no issues found. Startup manifest fetches now abort after a fixed deadline, clear the timer on every path, and report server errors separately; tests cover header/body stalls and timer cleanup. Targeted suite: 51 tests OK.

AI-assisted (OpenCode).

@tupacfan04

Copy link
Copy Markdown
Contributor

Approved by static review (Node is not installed here); merge clean.

The 10 s deadline covers headers and body, and the timer is cleared in finally on success, 404, HTTP error, parse error and abort (viewer/index.html:99-113). Abort is distinguished from parse/unreachable failures with distinct messages, test mode returns before scheduling, and world.reason is shown (:403). The tests cover both stall phases and cleanup.

Minor: a valid manifest that merely takes >10 s in total also times out - intentional per the body - and tests/test_viewer_streaming.cjs:124 reuses unreset fake-timer arrays, though the scheduled-count assertion still catches regressions.

Approve. AI-assisted review, no game files, no GPU.

@Atomic258

Atomic258 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 2baf85b on Windows with Node.js 26.13.0. node --test tests/test_viewer_streaming.cjs passed all 51 tests, including the stalled-header and stalled-body timeout cases. This was a synthetic test run with no game files, browser, or GPU required.

Codex AI review.

@olegmkrv
olegmkrv force-pushed the viewer/manifest-startup-timeout branch from 2baf85b to ab17b8d Compare November 23, 2026 07:49
@SweatierKey

Copy link
Copy Markdown
Contributor

Independent verification on Linux (Node.js v20.19.2, head ab17b8db, base main 3faac557):

  • node --test tests/test_viewer_streaming.cjs — 51/51 pass (161.9ms), including both stalled-manifest timeout phases (headers and body), HTTP 503 status reporting, timer cleanup on success, and ?test skipping timer creation.
  • git diff --check origin/main...HEAD — clean.
  • Diff review: WORLD_MANIFEST_TIMEOUT_MS = 10_000 with AbortController covers both fetch() and response.json(), finally { clearTimeout(timer); } ensures no leaked timer on any exit path (success, 404, non-OK HTTP, parse error, abort), and checking controller.signal.aborted keeps timeout distinct from unreachable/invalid-JSON errors.

Looks good to merge.

@KkelebekK

Copy link
Copy Markdown

Reviewed ab17b8db (diff read, tests run on head, red/green against the merge-base viewer, merge with main tested): concern — the fix is right, but merged onto current main 3faac557 the test file has 1 failure (AbortController is not defined).

  • Earlier reviews and tests are on 2baf85b0; the head is now a single commit ab17b8db (2026-11-23 07:49Z, same merge-base aa2988cc). 2baf85b0 is no longer fetchable (force-pushed), so I did not diff old head against new one; everything below is on ab17b8db.
  • Code (viewer/index.html:55,97-113): one AbortController and a 10 s setTimeout cover both fetch and response.json(); finally { clearTimeout(timer) } runs on every path (404/HTTP error return inside the try, parse error, abort). Aborted -> "download timed out"; no response -> "could not be loaded"; response but bad body -> "valid JSON". Test mode returns before the timer is created. I found no input that leaves the timer uncleared or the stall un-aborted.
  • Head tests: node --test tests/test_viewer_streaming.cjs (Node v22.23.5): 51 tests, 51 pass.
  • Red before: head's test file with viewer/index.html from the merge-base (git show aa2988cc:viewer/index.html): 47 pass, 4 fail (headers, body, "a stalled world manifest falls back…", "manifest success clears the deadline…"). Green after: 51/51 with the PR's index.html. (Using today's main index.html instead is not a valid red: 24 of 51 fail since the head's tests predate main's viewer changes.)
  • Merge: git merge-tree --write-tree origin/main pr3907-r is clean (no textual conflict), but in the detached merge worktree (removed after) node --test tests/test_viewer_streaming.cjs gives 55 tests, 54 pass, 1 fail: not ok 15 - Shift speeds the camera up and Ctrl slows it down, on either side of the keyboard, ReferenceError: AbortController is not defined (thrown from loadWorld in the viewer module). main itself is 51/51. Cause: that test (added to main by 698d270; main's tests/test_viewer_streaming.cjs:296-334) runs the whole viewer module in a vm context without AbortController, setTimeout, clearTimeout, and loadWorld now needs them. The PR already adds them to the sibling bounds-overlay context (head line 329) but not to this one.
  • Fix checked: adding AbortController, setTimeout, clearTimeout, to that context (next to fetch: manifestResponse({ spawn: [0, 0, 0], chunks: [] }), main line 334) makes the merge 55/55. Needs a rebase with that line.
  • Not checked: a real browser or real HTTP stall (relied on the vm tests plus the Windows loopback checks already posted for 2baf85b0).

AI-assisted.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: head ab17b8dbb (base 3faac557b, Windows 11)

  • node --test tests/test_viewer_streaming.cjs -> 51 tests, 51 pass, 0 fail, 0 skipped
  • git diff --check -> clean

The new tests cover a stall before headers and a stall while reading the JSON body: the 10 s timer aborts the fetch, loadWorld returns generated terrain with a timed out reason, and the deadline is cleared. They also assert ?test never schedules the timer, a successful manifest clears it, and HTTP 503 gets its own message. AbortController/setTimeout/clearTimeout were added to the vm contexts that need them; the rest of the file still passes.

Verdict: pass.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested ab17b8d on Windows Server 2022, CPython 3.13.12: pass

  • node tests/test_viewer_streaming.cjs -> pass 51, fail 0 (Node v24.22.2)
  • Negative control (viewer/index.html swapped to upstream/main): fails on the new retry-cancellation cases

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted independent review. At ab17b8d a Windows CPU loopback fixture stalled first before headers and separately during a partially delivered JSON body. Both triggered generated terrain with the timeout message at about 10 seconds. A valid manifest cleared the timer, and explicit test mode scheduled no timer and sent no request. All 51 tests passed standalone; 52 passed with the #5283 HUD change at dc12c72.

@S1m0ne1997

Copy link
Copy Markdown
Contributor

Thanks for this, @olegmkrv. The same change, "Viewer: time out stalled startup manifests (TEST-858)", is already on main as 2baf85b03 (this PR's diff is fully present on main 867d922f0). Could you close this PR when you have a moment?

(PR cleanup, #8919; AI-assisted, Claude Code)

@ramenbellic

ramenbellic commented Nov 23, 2026 •

Copy link
Copy Markdown

This was merged into main as 04975128e ("Merge pull request #3907"), and the commits pushed after that are on main as well: merging the current head ab17b8dbb onto main 867d922f0 changes no file. There's nothing left to merge, so it can be closed.

(Checked with git merge-tree --write-tree main <head>: the result is identical to main's tree.)

(PR cleanup: #8919.) AI-assisted (Claude Code).

@rideinstead

Copy link
Copy Markdown

✅ Automated security review: CLEAN (commit ab17b8db)

  • No findings.

Scope: static analysis of added diff lines only; no code was executed. Please review findings manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.