Title: id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, non-integer chunk_bytes corrupts the chunk stream · Issue #5034 · developing-today/code · GitHub
Open Graph Title: id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, non-integer chunk_bytes corrupts the chunk stream · Issue #5034 · developing-today/code
X Title: id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, non-integer chunk_bytes corrupts the chunk stream · Issue #5034 · developing-today/code
Description: id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, and a non-integer chunk_bytes corrupts the chunk stream Evidence Verified at origin/main 125789d in the ...
Open Graph Description: id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, and a non-integer chunk_bytes corrupts the chunk stream Evidence...
X Description: id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, and a non-integer chunk_bytes corrupts the chunk stream Evidence...
Opengraph URL: https://github.com/developing-today/code/issues/5034
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, non-integer chunk_bytes corrupts the chunk stream","articleBody":"# id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, and a non-integer chunk_bytes corrupts the chunk stream\n\n## Evidence\n\nVerified at origin/main 125789ddb in the laptop tree. In `pkgs/id/web/src/world.ts`:\n\n- `:618` (module-upload socket) — `frame = JSON.parse(String(message.data)) as typeof frame;` and `:739` (Roc-compile socket) — the same cast to `WorldFrame`. The `try` covers only the parse; the very next reads (`frame.type` at `:624` / `:745`) are unguarded.\n- `:631-636` — the only `chunk_bytes` validation is `!chunkBytes || chunkBytes \u003c 1 || chunkBytes > 6 * 1024`: no integer/type check, so a fractional or string `chunk_bytes` passes and drives the chunk loop at `:641` (`offset += chunkBytes`, `file.slice(offset, offset + chunkBytes)`, `install_chunk` frames carrying that offset).\n- Contrast in the same file: the main world `receive()` at `:188-200` parses to `unknown`, requires `isRecord(parsed)` and `typeof parsed.type === \"string\"`, and calls `rejectFrame()` otherwise. The upload/compile handlers skip the file's own established guard.\n- The server side expects integer offsets: `pkgs/id/src/world_session/types.rs:287` and `:357` type `install_chunk`'s `offset` as `usize`.\n\nReproduction (laptop probe `~/git/fleet/probe-2026-11-03-laneB-worldframe/probe.mjs`, replicating the handler logic at :616-645 verbatim with stubbed socket/file; run with bun at 125789ddb):\n\n```\nnull => UNCAUGHT THROW: TypeError - null is not an object (evaluating 'frame.type') | no status, socket never closed\n123 / \"hi\" / [1,2] => no branch matched, socket left open, no status shown (flow hangs; install button stays disabled until a close that never comes)\n{\"type\":\"upload_ready\",\"chunk_bytes\":100.5} => install_chunk offsets sent: 0, 100.5, 201, ... (fractional offsets the server's usize field rejects)\n{\"type\":\"upload_ready\",\"chunk_bytes\":\"512\"} => offsets sent: 0, then the string \"0512\"; second chunk slices 1488 bytes (overlapping/oversized) — a corrupted chunk stream\n{\"type\":\"upload_ready\",\"chunk_bytes\":512} => control: offsets 0, 512, 1024 — correct\n{\"type\":\"error\"} => control: status shown, socket closed — correct\n```\n\n## Why it matters\n\nThese two handlers are the admin paths for installing a world program (wasm upload and Roc compile). Any malformed or unexpected frame from the host connection — a proxy/error page frame, a future server frame shape, a hand-rolled client test — either throws uncaught (no error surfaced, no cleanup), hangs the flow silently with the button disabled, or, for a non-integer `chunk_bytes`, sends a chunk stream the server cannot accept, failing the install opaquely partway through. The main socket in the same file already demonstrates the intended validation pattern, so the gap is an inconsistency, not a design choice.\n\n## Acceptance criteria\n\n- Both handlers validate the parsed frame before use (record + string `type`, mirroring `receive()`/`isRecord` in the same file); an invalid frame sets the existing \"invalid upload/compile response\" error status and closes the socket — no uncaught throw, no silent hang.\n- `chunk_bytes` is accepted only as a finite integer within the existing 1..=6144 range (`Number.isInteger`); anything else takes the existing \"invalid module chunk size\" path.\n- Web tests cover: `null`, a JSON number/string/array frame, fractional `chunk_bytes`, and string `chunk_bytes` for the upload handler (and the non-object cases for the compile handler); the existing world web tests still pass.\n","author":{"url":"https://github.com/apps/developing-today","@type":"Person","name":"developing-today"},"datePublished":"2026-11-03T17:16:57Z","url":"https://github.com/developing-today/code/issues/5034"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ca21f584-0656-e0ab-cbe2-81d80670819e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CFA4:167B3F:3577B3:4621D8:6B0763D9 |
| html-safe-nonce | f5267cbbcb8742d191a41f2730c06eef54e7fb2b6f969ad7020ed0a9b17252ac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkE0OjE2N0IzRjozNTc3QjM6NDYyMUQ4OjZCMDc2M0Q5IiwidmlzaXRvcl9pZCI6IjMxMzMzOTA4NTQyNjY3NzQ0ODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | eaab7cca92528b53c8ceed112487060589bd46105fb09f807862ad156ef66a1d |
| hovercard-subject-tag | issue:6187613192 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/5034/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a76733bcc426798e5eb41cfe5487a40c9f26e5d883af8a36a77a5bb1300232c0/developing-today/code/issues/5034 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a76733bcc426798e5eb41cfe5487a40c9f26e5d883af8a36a77a5bb1300232c0/developing-today/code/issues/5034 |
| og:image:alt | id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, and a non-integer chunk_bytes corrupts the chunk stream Evidence... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | developing-today[bot] |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7a557ecc960a3ae6e299fc66b0bc9132072f8860191648e6749fee5d3ff00d82 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bd845eb7947c1ed8c850f7ab415a51339d162de3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width