nwutils/nw-builder

unzipper failed. Emitted 'error' event on DuplexWrapper instance at #289

qq253498229 opened this issue · 8 comments

Issue Type

  • Bug Report
  • Feature Request
  • Other

Current/Missing Behaviour

Expected/Proposed Behaviour

Additional Info

  • Package version:
  • Operating System:
  • Node version:
  • NW.js version:
  • Repro link:
  • ...
nwbuild({
  version: '0.82.0',
  src: './temp',
  platform: 'win',
  arch: 'x64',
  cacheDir: './cache',
  outDir: './out',
  flavor: 'normal',
  logLevel: 'debug',
  downloadUrl: 'https://npmmirror.com/mirrors/nwjs',
}).then(() => fs.removeSync('./temp'));

yarn run v1.22.21
$ node build.mjs --platform=win64
node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: FILE_ENDED
    at Parse.pull (D:\own\wang-comic-downloader\nwjs\node_modules\unzipper\lib\PullStream.js:83:28)
    at Parse.emit (node:events:514:28)
    at Parse.<anonymous> (D:\own\wang-comic-downloader\nwjs\node_modules\unzipper\lib\PullStream.js:20:10)
    at Parse.emit (node:events:526:35)
    at finish (node:internal/streams/writable:937:10)
    at node:internal/streams/writable:918:13
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on DuplexWrapper instance at:
    at Parse.<anonymous> (D:\own\wang-comic-downloader\nwjs\node_modules\duplexer2\index.js:45:12)
    at Parse.emit (node:events:514:28)
    at Parse.pull (D:\own\wang-comic-downloader\nwjs\node_modules\unzipper\lib\PullStream.js:83:14)
    at Parse.emit (node:events:514:28)
    [... lines matching original stack trace ...]
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

What version of nw-builder are you on?

What version of nw-builder are you on?

4.5.0/4.4.2-beta.4/4.4.2

I found that the issue seems to occur only when decompressing macOS zip file include .app file on a Windows platform.

After decompression on a Windows platform, the .app file cannot be opened normally on the macOS platform, and I found that many files are missing.

I have tried using decompress, adm-zip, unzipper, and extract-zip, 7zip and windows embed zip tool, but all of these library have the same issue.

Is this be an issue with the operating system architecture, where it is not allowed to decompress macOS app package on Windows system?

Can you reproduce this on v4.5.3?

Turns out unzipping files fails uniformally across different tools - yauzl, yauzl-promise, unzipper, native unzip - to name a few.

On error, we could ask user to either retry decompression or redownload?

@ayushmanchhabra ,

Decompression does not necessarily fail in each version, however it is certain that this one corrupts the files with unzipper. If you are in LTS version of nodeJS or higher (16+ and 18+) this is completely blocked. With each unzip it is the folder which is corrupted the quickest solution and to replace unzipper with unzip-stream which allows you to keep exactly the same structure of the code without having a single error in sight.

the correction can be done like this:

import unzipper from "unzipper";

to

import unzipper from "unzip-stream";

this resolve the problem with wine #1002 too

I have replaced with unzipper with yauzl-promise. I think this package is a good long term solution.