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

Migrated from github.com/Trevato/SO-ARM100

/live closes any text frame over 4096 bytes with 1009 - the three-line cap plus its boundary tests #199

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

/live now closes any text frame over 4096 bytes with 1009, and src/lobby.test.ts has the three boundary tests. The type check didn't run: bun x tsc --noEmit failed here with "bun is unable to write files to tempdir: ReadOnlyFileSystem", and the forge's check will run it on this push.

Notes

shipped merged

opened this

/live now closes any text frame over 4096 bytes with 1009, and src/lobby.test.ts has the three boundary tests. The type check didn't run: bun x tsc --noEmit failed here with "bun is unable to write files to tempdir: ReadOnlyFileSystem", and the forge's check will run it on this push. The new tests and src/lobby.security.test.ts pass (32 tests). I did not run the full bun --cwd Software/so101 test.

  • Where the cap is: pull #25's branch doesn't exist on the forge, so the three lines weren't there to rely on. I wrote them in Software/so101/src/lobby.ts. In the message handler, after the binary check and before parsing, it counts frameBytes(data) and calls ws.close(TOO_BIG_CLOSE, "message too big") if the count is over MAX_FRAME (4096).
  • Tests:

- A 4096-byte JSON object gets the normal reply (an error for the unknown type) and the socket stays open. - A 4097-byte frame closes with 1009. - 1366 "€" characters (4098 bytes, but only 1366 characters long) close with 1009.

forge.json is untouched.

🤖 Generated with Claude Code

Closes #188

commented

/live now closes any text frame over 4096 bytes with 1009, and src/lobby.test.ts has the three boundary tests. The type check didn't run: bun x tsc --noEmit failed here with "bun is unable to write files to tempdir: ReadOnlyFileSystem", and the forge's check will run it on this push. The new tests and src/lobby.security.test.ts pass (32 tests). I did not run the full bun --cwd Software/so101 test.

  • Where the cap is: pull #25's branch doesn't exist on the forge, so the three lines weren't there to rely on. I wrote them in Software/so101/src/lobby.ts. In the message handler, after the binary check and before parsing, it counts frameBytes(data) and calls ws.close(TOO_BIG_CLOSE, "message too big") if the count is over MAX_FRAME (4096).
  • Tests:

- A 4096-byte JSON object gets the normal reply (an error for the unknown type) and the socket stays open. - A 4097-byte frame closes with 1009. - 1366 "€" characters (4098 bytes, but only 1366 characters long) close with 1009.

forge.json is untouched.

🤖 Generated with Claude Code

Approved

The cap is a three-line guard in the message handler, after the binary check and before JSON.parse. It counts bytes with the existing frameBytes and closes with TOO_BIG_CLOSE (1009). The tests cover 4096 bytes (handled, socket stays open), 4097 bytes (closes 1009) and 1366 three-byte characters (4098 bytes, closes 1009). That last case would fail if the check counted characters instead of bytes. I did not run the tests or the preview; this is from reading the diff. It adds no dependency and no scope. Two things to do next: (1) lobby.ts already sets maxPayload: MAX_FRAME on the WebSocketServer, so add a comment saying the guard is there because Bun may not enforce maxPayload, as frame-limit.ts notes, or the guard looks redundant. (2) Put the frame-limit import in alphabetical order with the other imports, after ./chat.ts.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs