thejoshwolfe/yauzl

race condition in test.js: Error: closed

thejoshwolfe opened this issue · 1 comments

After some amount of normal test output:

/home/josh/dev/yauzl/test/test.js:78
                if (err) throw err;
                               ^
Error: closed
    at ZipFile.openReadStream (/home/josh/dev/yauzl/index.js:262:37)
    at /home/josh/dev/yauzl/test/test.js:77:23
    at pendGo (/home/josh/dev/yauzl/node_modules/pend/index.js:54:3)
    at onCb (/home/josh/dev/yauzl/node_modules/pend/index.js:41:7)
    at AssertByteCountStream.<anonymous> (/home/josh/dev/yauzl/test/test.js:91:19)
    at AssertByteCountStream.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)
npm ERR! Test failed.  See above for more details.

The problem seems to be that we are deferring openReadStream until after entityProcessing.go lets us start. Since we're using yauzl's autoClose: true, we're missing the window of time when we can call openReadStream.

the solution to this issue is to use the option lazeEntries: true that #22 added.