Repository navigation
fix(xlsx): fitting a column after an edit stops once the document is closed - #34
Conversation
…closed The column fit runs after an edit's result comes back. When another document was opened in between, its worker calls failed with "Document closed", uncaught. The client now says whether it is closed (`closed`), and the fit does nothing more once it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pierreneter
left a comment
There was a problem hiding this comment.
Thanks, this is right and nicely small. run() already catches a failed xlsx.set, xlsx.format or sheetOp, so the only uncaught rejection after a close was the rowsOf read in widen, and that is the one this covers. The closed check before each colWidth also saves a "Document closed" toast on a viewer that is going away.
One thing about merge order: the same change is in the stack as 04406ad (#8), with one word different in the comment ("another one opened" here, "a new one opened" there). Git sees two different edits of the same line, so whichever lands second conflicts in src/react/xlsx/XlsxView.tsx (checked with git merge-tree against #8's head b50e54d). Since this one has the test, I'd merge it first and drop 04406ad from #8, or make the two lines identical.
Non-blocking: the test covers the closed getter, not widen itself. That is fine for a change this size.
After a number is typed into a cell,
wideninXlsxView.tsxfits its column once the edit's result comes back, reading the rows from the worker. When another document is opened in that moment (a host that switches files, or a viewer given a newsrc), the client of the first one is already destroyed, so those reads fail with "Document closed" and the rejection goes uncaught. The same happens after a number format is applied.DocumentClientnow has aclosedgetter, andwidenstops when the document is closed: before it starts, when its row read fails because of that, and before each column width it sets. Any other error still surfaces.test/client-closed.test.tschecks that a client reports itself closed afterdestroy()and that a call then fails with "Document closed".bun run typecheck,bun testand the e2e suite pass in CI.🤖 Generated with Claude Code