Skip to content

Wait for extraction to finish before reporting a download install complete - #1009

Open
X-Guardian wants to merge 1 commit into
mapbox:masterfrom
X-Guardian:fix/install-extract-race
Open

X-Guardian wants to merge 1 commit into
mapbox:masterfrom
X-Guardian:fix/install-extract-race

Conversation

@X-Guardian

Copy link
Copy Markdown
Contributor

place_binary in lib/install.js resolves when the HTTP response body ends, not when tar has finished writing the extracted files. The callback can therefore fire while the binary is still being written, and install goes straight on to load it with testbinary.

Extracting a 5 MB file from a local tarball and checking its size at each event shows the gap, identically across three runs:

source end, size 4962648
extract close, size 5000000

Effects

Truncated binary. On a slow or scanned filesystem (Windows with antivirus is the likely case) testbinary can load a partly written .node file and fail, or install can report success while the file is still incomplete.

Lost errors. An extraction error raised after the response ends is dropped, because the promise has already resolved and the later reject does nothing.

Change

Resolve on the tar extract stream's close instead of the source's end, keeping the existing rejects on errors from either stream. This matches the other two extract paths in the same file: the authenticated S3 download (place_binary_authenticated) and extract_from_local both already wait for close.

@X-Guardian
X-Guardian requested a review from a team as a code owner September 30, 2026 09:26
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.

1 participant