End of Central Directory Record not found
thisjt opened this issue · 7 comments
Issue Type
- Bug Report
- Feature Request
- Other
Current/Missing Behaviour
During an nw build process, this error gets thrown:
Error: End of Central Directory Record not found
at Zip._locateEocdr (D:\thisjt-projects\demo\node_modules\.pnpm\yauzl-promise@4.0.0\node_modules\yauzl-promise\lib\zip.js:143:9)
at async Zip._init (D:\thisjt-projects\demo\node_modules\.pnpm\yauzl-promise@4.0.0\node_modules\yauzl-promise\lib\zip.js:106:23)
at async Object.open (D:\thisjt-projects\demo\node_modules\.pnpm\yauzl-promise@4.0.0\node_modules\yauzl-promise\lib\index.js:57:2)
at async unzip (file:///D:/thisjt-projects/demo/node_modules/.pnpm/nw-builder@4.7.7/node_modules/nw-builder/src/get/decompress.js:49:15)
at async decompress (file:///D:/thisjt-projects/demo/node_modules/.pnpm/nw-builder@4.7.7/node_modules/nw-builder/src/get/decompress.js:16:5)
at async get (file:///D:/thisjt-projects/demo/node_modules/.pnpm/nw-builder@4.7.7/node_modules/nw-builder/src/get/index.js:99:3)
at async nwbuild (file:///D:/thisjt-projects/demo/node_modules/.pnpm/nw-builder@4.7.7/node_modules/nw-builder/src/index.js:87:5)
at async Step (file:///D:/thisjt-projects/demo/Build.js:145:4)
at async Builder (file:///D:/thisjt-projects/demo/Build.js:87:4)
However, I did notice that even though the error is thrown, the script pauses for a few minutes, which is suspiciously similar to how long a binary gets downloaded. After the script ends, when I rerun the script, the build runs normally again without any issues.
Expected/Proposed Behaviour
No error gets thrown. The build runs successfully without issues.
Additional Info
Build script step:
case 'nw:build':
throbber.info('Compiling NWJS App...');
await nwbuild({
mode: 'build',
platform: 'win',
arch: 'x64',
outDir: 'dist',
srcDir: './build/nw',
glob: false,
version: 'stable',
flavor: 'sdk',
cache: true,
name: branding.server_filename,
app: {
company: 'thisjt/demo',
version: buildId,
comments: `${branding.server_description}`,
fileDescription: `${branding.server_description}`,
originalFilename: `${branding.server_filename}`,
productName: `${branding.name} - DEMO`,
productVersion: buildId,
internalName: `${branding.server_filename}`,
fileVersion: buildId,
legalCopyright: '(c) 2020 thisjt',
legalTrademarks: '(tm) demo',
legalTrademark: '(tm) demo',
icon: `${branding.server_icon}`,
name: `${branding.slug}-server`,
},
managedManifest: {
...info.nwmanifest,
...{
name: `${branding.slug}-server`,
version: buildId,
additional_trust_anchors: [
fs
.readFileSync('./src/ssl/demo.crt')
.toString()
.replace(/\r?\n|\r/g, '\n'),
],
},
},
});
break;
- Package version: nw-builder 4.7.7
- Operating System: Windows 10
- Node version: 20.13.1
- NW.js version: 0.88.0
- Repro link: N/A
this error is thrown because nw-builder is not downloading the file properly from the mirror for some reason but makes a zip file anyways and thats why yauzl-promise\lib\zip.js
throws the error because it's a corrupted/not proper zip file.
the funny thing is when i download one of the repo's from https://nwutils.io/ it works just fine so there is something prolly wrong with our code :p
oh and btw you can just download the sdk or the normal zip n unzip it in the cache folder and the build should work.
Found the root cause of the issue it's the new version.
In line 26 of the src\get\request.js
of the released 4.7.7
version is response.data.pipe(writeStream);
which is not waiting for the download to finish and the await decompress(nwFilePath, options.cacheDir);
gets called which throws a End of Central Directory Record not found
because it's a corrupted/unfinished zip file and the program quits (atleast on windows).
The 28th line in src\get\request.js
which is await stream.promises.pipeline(response.data, writeStream);
works correctly but is commented out. On the main branch also this line is uncommented so everything works properly.
The current workaround is to comment out the line 26 in node_modules and uncomment line 28 or use v4.7.5
That does seem to be the case. After the script fails, the command does not really terminate until, I'm assuming, the file finishes downloading in the background. When I run the script again it succeeds now as it skips the download process and continues using the downloaded file.
In the current main
branch this has been fixed, but on v4.7.7
it's commented out. I think the fix for this is a re-release on the latest main
branch,
main
Line 26 in 61189de
v4.7.7
Line 28 in 1cdbdd1
@ayushmanchhabra for visiblity. Sorry for tagging, please do tell me if I shouldn't be doing it.
I made the change in source but forgot to create a release
Please try v4.7.8
Confirmed working fine now for v4.7.8
. Thanks!
Sorry for tagging, please do tell me if I shouldn't be doing it.
All good! I keep all notifs off so tagging is the best way to reach me