task/fs/encryptToArchive(): fix race condition#1752
Open
alxndrsn wants to merge 4 commits intogetodk:masterfrom
Open
task/fs/encryptToArchive(): fix race condition#1752alxndrsn wants to merge 4 commits intogetodk:masterfrom
alxndrsn wants to merge 4 commits intogetodk:masterfrom
Conversation
Noted while investigating getodk/central#1645. Defer promise resolution until destination stream has completed. Previously, `Promise.resolve()` was called when the source stream completed. Fixes the following when trying to decrypt the zip file too quickly after `await encryptToArchive()` returned: Error: End of central directory record signature not found. Either not a zip file, or file is truncated. at node_modules/yauzl/index.js:190:14 at node_modules/yauzl/index.js:772:5 at node_modules/yauzl/fd-slicer.js:33:7 at FSReqCallback.wrapper [as oncomplete] (node:fs:669:5)
added 2 commits
February 15, 2026 13:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Noted while investigating getodk/central#1645.
Defer promise resolution until destination stream has completed. Previously,
Promise.resolve()was called when the source stream completed.Fixes the following when trying to decrypt the zip file too quickly after
await encryptToArchive()returned:What has been done to verify that this works as intended?
Ran tests with & without this fix a few thousand times:
Added a test.
Why is this the best possible solution? Were any other approaches considered?
No other approaches were considered.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
This is a bug fix, but hopefully the bug is infrequent.
Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.
No.
Before submitting this PR, please make sure you have:
make testand confirmed all checks still pass OR confirm CircleCI build passes