v31.7: silence ERR_INVALID_URL fetch noise in SSR build #8

Merged
og_arist0tle merged 1 commit from fix/ssr-build-fetch-noise into main 2026-07-25 19:07:28 +00:00
Contributor

What

Every ssr-server.py / ssr-build.mjs run logged a TypeError: Failed to parse URL from /api/players stack trace during the build.

Why

ssr-build.mjs imports main.js under a mocked DOM to capture initial state, which triggers the module-level boot() and its fetch('/api/players') probe. Browser fetch resolves relative URLs against the page origin; Node's fetch has none, so it throws ERR_INVALID_URL. SaveManager.listPlayers() caught it and logged the noisy warning — harmless (build exits 0), but the noise buries real errors, same rationale as issue #1.

Fix

Stub globalThis.fetch alongside the existing DOM mocks in ssr-build.mjs, answering like a server with no saves (ok: false) — identical code path in SaveManager, no behavior change, no spam.

Also includes the routine index.html version-stamp catch-up rebuild (v30.57 / 6b613c9).

Verified

  • node scripts/ssr-build.mjs — clean output, exit 0, byte-identical HTML apart from stamps
  • Server smoke test: GET / → 200, /api/players returns existing saves, zero SaveManager lines in the log

https://claude.ai/code/session_012C3yuNh2Zdr8YWQb6nmn8R

## What Every `ssr-server.py` / `ssr-build.mjs` run logged a `TypeError: Failed to parse URL from /api/players` stack trace during the build. ## Why `ssr-build.mjs` imports `main.js` under a mocked DOM to capture initial state, which triggers the module-level `boot()` and its `fetch('/api/players')` probe. Browser fetch resolves relative URLs against the page origin; Node's fetch has none, so it throws `ERR_INVALID_URL`. `SaveManager.listPlayers()` caught it and logged the noisy warning — harmless (build exits 0), but the noise buries real errors, same rationale as issue #1. ## Fix Stub `globalThis.fetch` alongside the existing DOM mocks in `ssr-build.mjs`, answering like a server with no saves (`ok: false`) — identical code path in `SaveManager`, no behavior change, no spam. Also includes the routine `index.html` version-stamp catch-up rebuild (v30.57 / 6b613c9). ## Verified - `node scripts/ssr-build.mjs` — clean output, exit 0, byte-identical HTML apart from stamps - Server smoke test: `GET /` → 200, `/api/players` returns existing saves, zero `SaveManager` lines in the log https://claude.ai/code/session_012C3yuNh2Zdr8YWQb6nmn8R
ssr-build.mjs imports main.js under a mocked DOM, which triggers the
module-level boot() and its fetch('/api/players') probe. Node's fetch
has no page origin, so the relative URL throws ERR_INVALID_URL —
caught and logged by SaveManager.listPlayers as a noisy stack trace on
every build. Harmless (build exits 0) but buries real errors.

Stub globalThis.fetch alongside the existing DOM mocks to answer like
a server with no saves (ok: false) — same code path, no spam.

index.html: routine version-stamp catch-up rebuild (v30.57 / 6b613c9).

Claude-Session: https://claude.ai/code/session_012C3yuNh2Zdr8YWQb6nmn8R
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
og_arist0tle/dark-spire!8
No description provided.