pack: skip sockets so create does not hang - #466
Closed
dyk1454683243-sudo wants to merge 2 commits into
Closed
dyk1454683243-sudo wants to merge 2 commits into
dyk1454683243-sudo wants to merge 2 commits into
Conversation
WriteEntry treats sockets, FIFOs, and devices as Unsupported and ends with no header. That completion can run while the job is still read-ahead, and JOBDONE always shift()s the queue head, so two such entries after a regular file stall tar.create. Skip those types in Pack, matching GNU tar. Fixes isaacs#295 Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
Delay lstat of the regular file so two sockets are processed as read-ahead while it is still the queue head. That is the isaacs#295 corruption: JOBDONE shift()s the file off the queue and Pack never ends. The new pack.js test hangs on 2a22bfc and passes with the skip. Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
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.
Fixes #295
Problem
tar.createhangs when a directory contains more than one Unix socket after a regular file in readdir order (the/var/runcase). GNU tar skips sockets and finishes.A single socket, or sockets that sort before every regular file, already completed. The hang is pack-queue corruption, not
fs.openblocking on the socket.WriteEntryclassifies sockets, FIFOs, and devices asUnsupportedand callsend()with no header. Minipass emitsendimmediately on an empty stream. Pack still creates thatWriteEntryas a read-ahead job, andJOBDONEalwaysshift()s the queue head. Two such completions pop the file that is still being packed;JOBSnever drains; thecreate({ file })promise never settles.Reproduced on 7.5.22 (
2a22bfc):aaa.txt+b.sock+c.sockwith delayed filelstat→ Pack times outa.sock+b.sock+zzz.txt→ completes (unsupported jobs are current when they end)aaa.txt+ one socket → completesFix
In
Pack/PackSyncPROCESSJOB, ignore stats that are not a file, directory, or symlink before constructingWriteEntry. Same skip GNU tar uses for sockets; FIFOs and device nodes were already unsupported on create.Tests
test/pack.js(#295): delayedlstatof the regular file so two sockets are processed as read-ahead. Hangs on2a22bfc, passes with the skip.test/create.ts(#295): async / sync / gzipcreate({ file })and socket-as-sole-entry. Archive contains the regular files only.Test plan
pack.jstest:Pack hungon2a22bfc, pass on this branchnpx tap test/create.ts --disable-coverage -t0: 70/70 passnpx tap test/pack.js --disable-coverage -t0 -g '#295': passtest/pack.jsin this environment fails on a pre-existing zstdZstdCompressgap (Node 22.14); not caused by this change. CI uses Node 22/24/26.