v31.7: silence ERR_INVALID_URL fetch noise in SSR build #8
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
og_arist0tle/dark-spire!8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/ssr-build-fetch-noise"
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?
What
Every
ssr-server.py/ssr-build.mjsrun logged aTypeError: Failed to parse URL from /api/playersstack trace during the build.Why
ssr-build.mjsimportsmain.jsunder a mocked DOM to capture initial state, which triggers the module-levelboot()and itsfetch('/api/players')probe. Browser fetch resolves relative URLs against the page origin; Node's fetch has none, so it throwsERR_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.fetchalongside the existing DOM mocks inssr-build.mjs, answering like a server with no saves (ok: false) — identical code path inSaveManager, no behavior change, no spam.Also includes the routine
index.htmlversion-stamp catch-up rebuild (v30.57 /6b613c9).Verified
node scripts/ssr-build.mjs— clean output, exit 0, byte-identical HTML apart from stampsGET /→ 200,/api/playersreturns existing saves, zeroSaveManagerlines in the loghttps://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