fix(planner): raise WS frame cap above doc cap (fixes sync reconnect loop)
The Yjs sync WebSocket had MAX_MESSAGE_BYTES = 256 KB (per frame) but MAX_DOC_BYTES = 5 MB (per session doc). A full-state sync frame carries the entire doc, so any session doc between 256 KB and 5 MB was allowed to exist yet could never sync: the client's sync frame tripped the 256 KB per-frame cap, the server closed it (1008), the client reconnected, resent the same oversized frame, and looped forever — the UI froze, the connection flapped Verbunden/Verbinde, and the network tab filled with 101 reconnects. Real routes hit this fast because the BRouter geometry is stored in the doc: a 4-waypoint, 77 km cycling route was already 305 KB. Fix: the per-frame cap must be >= the doc cap (a full-doc sync must fit in one frame). Set MAX_MESSAGE_BYTES = MAX_DOC_BYTES + 256 KB overhead; the 5 MB doc cap stays the real size/abuse guard. Updated the test that had codified the inverted ordering. Verified: planner typecheck + lint clean, yjs-server 9/9, planner suite 183/183. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
696ffb7306
commit
e34a06ff5a
2 changed files with 18 additions and 9 deletions
|
|
@ -52,9 +52,12 @@ describe("countActiveSessions", () => {
|
|||
});
|
||||
|
||||
describe("doc-size caps", () => {
|
||||
it("MAX_MESSAGE_BYTES + MAX_DOC_BYTES are positive and ordered sanely", () => {
|
||||
expect(MAX_MESSAGE_BYTES).toBeGreaterThan(0);
|
||||
expect(MAX_DOC_BYTES).toBeGreaterThan(MAX_MESSAGE_BYTES);
|
||||
it("the per-frame cap can carry a full-doc sync (message cap >= doc cap)", () => {
|
||||
expect(MAX_DOC_BYTES).toBeGreaterThan(0);
|
||||
// A full-state sync frame contains the entire doc, so a per-frame cap
|
||||
// below the doc cap makes docs between the two sizes unsyncable (reconnect
|
||||
// loop). The frame cap must be at least the doc cap, plus protocol room.
|
||||
expect(MAX_MESSAGE_BYTES).toBeGreaterThanOrEqual(MAX_DOC_BYTES);
|
||||
});
|
||||
|
||||
it("docByteSize returns 0 for an unknown session", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue