I shipped realtime collaboration and nobody could connect
ForgeSheets is a work grid — rows with hierarchy, columns with types, the thing people reach for Smartsheet or a badly abused spreadsheet to do. In one week in July it went from a single-file demo to something several people can edit at once.
The build order was roughly: a tree-structured grid with undo and real clipboard support. A formula engine I wrote by hand — tokenizer, parser, evaluator, thirteen functions, and a CHILDREN() rollup so a parent row can summarise what’s under it. Six report templates. Local-first file storage through the File System Access API, so your data can live in a file you own rather than my database. Then accounts, a worker API, and sharing with roles and single-use invites.
Then realtime, on the 24th, in a day.
One room per workspace
Each workspace gets a Durable Object — one authoritative process, the only thing allowed to decide what order operations happen in. Everyone connects to it over a WebSocket.
The piece I’d do the same way again: the operations module is pure and runs identically on the client and inside the Durable Object. Same code, same inputs, same result. The client applies an edit locally so it feels instant, the room applies the same edit to decide what really happened, and when they disagree the room wins. Collaborative editing has plenty of ways to go wrong without adding two different implementations of what an edit means.
With that in place, presence avatars and live peer cursors were nearly free.
And then nobody could connect
I launched it. Every browser trying to open a collaborative session got a 401.
The worker had a global gate: check the bearer token in the Authorization header, reject if it’s missing. Perfectly reasonable, and it covered every REST route correctly.
But a browser can’t set an Authorization header on a WebSocket handshake. The API doesn’t let you — no option, no flag, no workaround. The handshake is a GET the browser builds, and your JavaScript doesn’t get to add headers to it.
So the global gate saw no bearer token, returned 401, and the request never reached the WebSocket route, which had its own perfectly good authentication using the subprotocol field, the standard way around this exact limitation. My own correct code was sitting behind a door that closed before it.
What makes this interesting rather than just embarrassing: a REST-only test suite can’t catch it. Every test passed. The failure needs two browser tabs trying to reach the same Durable Object, which is the one thing a unit test doesn’t do. The fix detects the upgrade header at the very top of request handling and branches around the bearer gate entirely, and there are eight tests pinning that route’s auth matrix now.
Twenty times faster by doing less
The performance fix I closed July with is my favourite kind. A 5,000-row sheet with an active selection took 1,264ms to render. It takes 62ms now.
The old code swept the entire document twice on every render — once to clear selection classes off every cell, once to apply them to the selected ones — across about 40,000 cells. So scrolling a large sheet did forty thousand operations to change the appearance of maybe twenty.
The new version tracks a signature of what’s currently on screen and only touches elements that actually carry a class worth removing. No cleverness, no virtualisation rewrite. Just not doing work that was never needed.
What’s honestly not right yet
Undo is disabled while you’re collaborating. That’s a real limitation and I knew it when I shipped. Undo in a shared document is hard, because undoing “your” change when three other people have edited since isn’t a well-defined request. Turning it off is honest. It isn’t a solution.
And select columns shipped with options literally called “Option A,” “Option B” and “Option C,” with no way to rename them. That stayed true for four months, which isn’t a bug so much as a thing I kept not doing because it wasn’t interesting.
133 commits, and the test count went from 482 to over 1,697 across the month. Live behind a gate at sheets.echoforge.games.
— Bruno