Public: anyone can read this; the crew can change it.

A map file over 600 KB is served in parts instead of failing the whole 3D view #18350

opened this

Merged 18m ago, live in production

A map file over 600 KB now arrives whole, in slices, instead of failing with a 502. test/games-map.test.ts and the unused-exports test pass, and tsc is clean. I did not run a real BlueMap, and the agent's new curl path has no test, so I only checked agent.sh with bash -n.

Notes

opened this

A map file over 600 KB now arrives whole, in slices, instead of failing with a 502. test/games-map.test.ts and the unused-exports test pass, and tsc is clean. I did not run a real BlueMap, and the agent's new curl path has no test, so I only checked agent.sh with bash -n. fast.ts named 2,922 test files for this change, so I ran only the map and unused-exports tests and left the rest to the forge's check.

  • Agent (src/games/agent.sh): a bare path now fetches its first 512,000 bytes with curl -r. A command text of path#from-to fetches that slice, and a slice of 600,000 bytes or more is refused. When BlueMap answers 206, the reply says the whole file's size in its flag line (0 1500000\n<base64>). A server that ignores ranges and sends a whole file of 600 KB or less still works as before.
  • Joining (src/games/map.ts): askMap asks the first slice, reads the total from it, then asks the remaining slices one at a time and joins them. Each slice is its own command row, so MAP_PENDING and MAP_PER_PERSON count it. Each row is deleted as it is read. A slice with an unexpected total or no bytes is a 502.
  • Ceiling: it is 8 MiB, set by FORGE_GAME_MAP_MOST (in bytes, never below one slice), and the reason is beside it in the code. It rests on the largest BlueMap files being a few MB and on the forge holding all slices in memory until the file is whole. A file past it answers 413 with "…larger than the 8 MB the forge joins…", and no further slice is asked.
  • Words and docs: mapWords.tooBig now means a server that ignores ranges and sends over 600 KB, and mapWords.tooLarge is the new 413 sentence. docs/features/game-map.md is updated.
  • Tests: a 1.5 MB file arrives byte-identical in three slices, with no rows left. A file declared at 9 MiB is a 413 naming the ceiling, and nothing past the first slice is asked.
  • Doors: the page and the terminal both call askMap, so both gain it. The commit says No door: for that reason.
  • Reused: queueCommand, commandOf, watchBox and the existing result path.

I did not parallelize the slices: they go one at a time, so a 1.5 MB file costs about three check-ins, and the 12-second wait now applies to each slice. I also did not add a setting in the games settings UI; it is an environment variable. Agents that predate this change refuse a path#from-to command, so rolling out the new agent is what lets large files through.

Closes #18344

2 earlier comments
commented

A map file over 600 KB now arrives whole, in slices, instead of failing with a 502. test/games-map.test.ts and the unused-exports test pass, and tsc is clean. I did not run a real BlueMap, and the agent's new curl path has no test, so I only checked agent.sh with bash -n. fast.ts named 2,922 test files for this change, so I ran only the map and unused-exports tests and left the rest to the forge's check.

  • Agent (src/games/agent.sh): a bare path now fetches its first 512,000 bytes with curl -r. A command text of path#from-to fetches that slice, and a slice of 600,000 bytes or more is refused. When BlueMap answers 206, the reply says the whole file's size in its flag line (0 1500000\n<base64>). A server that ignores ranges and sends a whole file of 600 KB or less still works as before.
  • Joining (src/games/map.ts): askMap asks the first slice, reads the total from it, then asks the remaining slices one at a time and joins them. Each slice is its own command row, so MAP_PENDING and MAP_PER_PERSON count it. Each row is deleted as it is read. A slice with an unexpected total or no bytes is a 502.
  • Ceiling: it is 8 MiB, set by FORGE_GAME_MAP_MOST (in bytes, never below one slice), and the reason is beside it in the code. It rests on the largest BlueMap files being a few MB and on the forge holding all slices in memory until the file is whole. A file past it answers 413 with "…larger than the 8 MB the forge joins…", and no further slice is asked.
  • Words and docs: mapWords.tooBig now means a server that ignores ranges and sends over 600 KB, and mapWords.tooLarge is the new 413 sentence. docs/features/game-map.md is updated.
  • Tests: a 1.5 MB file arrives byte-identical in three slices, with no rows left. A file declared at 9 MiB is a 413 naming the ceiling, and nothing past the first slice is asked.
  • Doors: the page and the terminal both call askMap, so both gain it. The commit says No door: for that reason.
  • Reused: queueCommand, commandOf, watchBox and the existing result path.

I did not parallelize the slices: they go one at a time, so a 1.5 MB file costs about three check-ins, and the 12-second wait now applies to each slice. I also did not add a setting in the games settings UI; it is an environment variable. Agents that predate this change refuse a path#from-to command, so rolling out the new agent is what lets large files through.

commented

I've addressed all three of juniper's points and the smaller ones. The two affected test files (test/games-map.test.ts, test/game-agent-exec.test.ts) pass, and tsc is clean. I didn't run the full suite or scripts/design-lint.ts, since no page changed.

  • Truncated file served as whole: a 206 with no numeric total (bytes 0-511999/*, or no Content-Range) now fails with the word unsized. The forge turns that into a 502 saying the server gave a part without the whole size (mapWords.unsized). It is never an ok result.
  • Empty file: a 416 on the first slice (from = 0) is asked again without -r, so an empty file gives a 200 with an empty body again. The retry has its own curl exit code, so refused, toobig and slow still map correctly.
  • Join loop: a slice longer than MAP_SLICE, or one that pushes have past total, is rejected as "not a file" (502).
  • Test through agent.sh: test/game-agent-exec.test.ts now runs the agent against a small local server that honours Range. It asserts:
    • the 0 700000 flag line and the slice lengths (512000 and 188000);
    • the "not a slice" refusal for to < from and for a span of 600000 or more;
    • unsized for a 206 without a total;
    • the empty-file 416 retry giving ok with an empty body.
  • Forge side: test/games-map.test.ts has a new test for the oversized slice and an unsized case in the failure-words test.
  • Docs: the "how it holds up" paragraph in docs/features/game-map.md now says an 8 MiB file is 17 sequential slices, each waiting up to 12 s. One request can hold a connection and up to 8 MiB for minutes, and one person can have 24 of them. The refusals list names unsized.

I didn't change any web page or terminal screen, so neither door is touched. The gate notes one over-100-column comment line in the test file; it is only a note, and I left it for the nightly rewrap.

commented

I merged main into the branch and pushed it. The merge had one conflict, in docs/features/game-map.md.

  • The conflict: both sides had edited the "How it holds up" bullet. I kept my slice-timing and refusal wording there, and added main's new "Whether it answers, before you open it" section unchanged. I also capitalised the "A first look" sentence, which my earlier edit had left lowercase.
  • Checks: tsc is clean, and the test/games-map.test.ts and test/game-agent-exec.test.ts suites pass (20 tests). scripts/gate.ts only notes the over-100-column comment in test/game-agent-exec.test.ts again. I didn't run the full suite; the forge runs it on the push.
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs