Skip to content

finish a chunked transfer when the length is an exact multiple - #2004

Merged
gildas-lormeau merged 2 commits into
gildas-lormeau:masterfrom
MaciejZet:fix/chunk-transfer-exact-multiple
Sep 27, 2026
Merged

gildas-lormeau merged 2 commits into
gildas-lormeau:masterfrom
MaciejZet:fix/chunk-transfer-exact-multiple

Conversation

@MaciejZet

Copy link
Copy Markdown
Contributor

Summary

A chunked save sets finished when the next offset is past the end of the payload. On an exact multiple of the chunk size that comparison stays false for the last block, so the background page never writes the file. The download fallback, the editor tab data, and the editor open path all used that comparison.

16 MiB still goes out as a single block. 32 MiB and 48 MiB now finish on the last block.

The fetch sender walks with <= and already marks the following empty block finished. That path is left as it is.

Test plan

  • test/chunk-finished.test.js: exact 2× and 3× chunks, one unit under and over, a single chunk, an empty payload, 16 / 32 / 48 MiB, and 32 MiB ± 1
  • npm test: 29 passed
  • eslint on the touched files
  • ./build.sh; the committed bundles include the same >= check

MaciejZet and others added 2 commits September 27, 2026 22:44
The last block used >, so a payload of 32 MiB or 48 MiB never set finished and the save stayed open.
@gildas-lormeau
gildas-lormeau merged commit 27f6667 into gildas-lormeau:master Sep 27, 2026
@gildas-lormeau

Copy link
Copy Markdown
Owner

Thanks! I removed chunkFinished and its test and kept the >= fix inline. It's a one-character change, so a helper module felt like too much.

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