Skip to content

fix(xlsx): fitting a column after an edit stops once the document is closed - #34

Merged
pierreneter merged 1 commit into
p10node:mainfrom
mkroemer:fix/xlsx-widen-closed
Nov 20, 2026
Merged

pierreneter merged 1 commit into
p10node:mainfrom
mkroemer:fix/xlsx-widen-closed

Conversation

@mkroemer

Copy link
Copy Markdown
Contributor

After a number is typed into a cell, widen in XlsxView.tsx fits 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 new src), 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.

DocumentClient now has a closed getter, and widen stops 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.ts checks that a client reports itself closed after destroy() and that a call then fails with "Document closed". bun run typecheck, bun test and the e2e suite pass in CI.

🤖 Generated with Claude Code

…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 pierreneter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pierreneter
pierreneter merged commit 038b316 into p10node:main Nov 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants