adm-zip icon indicating copy to clipboard operation
adm-zip copied to clipboard

Extracting zip causes Node to exit in 0.5.11+

Open jakebailey opened this issue 1 year ago • 4 comments

My repro is here: https://github.com/jakebailey/adm-zip-exit-bug

This manifested as https://github.com/jakebailey/every-ts/issues/58; after fetching and extracting, the files are written, but then the process just exits. Pinning back to 0.5.10 fixes the issue.

Reading https://app.renovatebot.com/package-diff?name=adm-zip&from=0.5.10&to=0.5.12, it's not entirely certain to me why this would be happening.

jakebailey avatar Mar 21 '24 17:03 jakebailey

Ah found it, it's the move of fileEntries.delete(entry); to after done(), introduced in https://github.com/cthackers/adm-zip/pull/437.

jakebailey avatar Mar 21 '24 18:03 jakebailey

We are having the same issue.

komyg avatar Mar 25 '24 11:03 komyg

Ah found it, it's the move of fileEntries.delete(entry); to after done(), introduced in #437.

yep, I was literally just going to open an issue. manually patching or reverting to 0.5.10 should fix the issue.

edit: running npm i && node ./index.js should reproduce the issue, console.log("resolve") (and the callback in general) is never called. adm-zip-extract-test.zip

hoancea avatar Mar 28 '24 14:03 hoancea

I am also experiencing a similar problem with 0.5.11 and 0.5.12. In the very simplified example below, I am unzipping an array buffer using extractAllToAsync:

async function doStuff(payload) {
  // Do some work and get the results as a zip archive
  const zipResponse = await axios.post(`/api/do-some-work`, payload, { responseType: 'arraybuffer' })

  // Extract the response to the target directory
  await new Promise((resolve, reject) => {
    let extract = new AdmZip(zipResponse.data)
    extract.extractAllToAsync('/path/to/files', true, false, (err: any) => {
      if (err) {
        reject(err)
      }
      resolve()
    })
  })
}

In v0.5.11 and 0.5.12, the result callback is never called, the promise is never resolved, and so the doStuff function never returns. So, a different symptom, but it seems like it could be related to the present issue. If not, I will gladly open a new issue with a fully reproducible example.

Thanks!

EDIT: I should have looked closer at jakebailey's example. It's exactly the same problem, so you can ignore my example.

ericman314 avatar Apr 17 '24 14:04 ericman314

Sadly, I cannot merge @WikiRik PR, any more - but I think I fixed this issue in repo few days ago with my own PR.

There are still some more tests to be done but I think it is fixed.

5saviahv avatar May 19 '24 10:05 5saviahv

Seems like this was fixed in 0.5.13+?

jakebailey avatar Jun 04 '24 14:06 jakebailey