serverless: Uploaded file must be a non-empty zip again with Node16
Are you certain it’s a bug?
- Yes, it looks like a bug
Is the issue caused by a plugin?
- It is not a plugin issue
Are you using the latest version?
- Yes, I’m using the latest version
Is there an existing issue for this?
- I have searched existing issues, it hasn’t been reported yet
Issue description
Hello,
seems like the problem Uploaded file must be a non-empty zip which was resolved in #8772 is now appearing again when using Node 16.15.1 (at point int time the latest lts version). Seems like the problem is again in node-archiver / crc32-stream. A workaround is available by using node <= 15.5.
Service configuration (serverless.yml) content
N/A
Command name and used flags
N/A
Command output
Uploaded file must be a non-empty zip
unzip .serverless/cloud-sensors.zip
Archive: cloud-sensors.zip
inflating: src/checks/check-executor.js bad CRC 64419a3d (should be 00000000)
Environment information
Framework Core: 3.18.2 (local)
Plugin: 6.2.2
SDK: 4.3.2
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 4
- Comments: 28 (7 by maintainers)
Commits related to this issue
- add resolution for node16 for sls lambda https://github.com/serverless/serverless/issues/11118 — committed to prisma/ecosystem-tests by millsp a year ago
tl;dr: Upgrade
serverless-webpackBackground I’m seeing this still with node 16.16 and serverless 3.21.0. When I unzip the packaged zips, I’m still seeing bad CRCs:
This is confirmed when unzipping:
@Bastczuak mentioned this may have something to do with node-archiver but says it was fixed for them in 3.21.0 (the same version I’m using): https://github.com/archiverjs/node-archiver/issues/594
My
serverless-webpackversion is 5.3.1 which is includingarchiver@2.1.1Solution When I upgraded
serverless-webpackto5.9.0, it requiresarchiver@5.3.1. I think this updated archiver version solved the bad CRCs which also solved the “empty file” problem on deploy.I think the new archiver includes a new version of
crc32-streamwhich was affected by thiszlibbehavior change in Node v15.6.0.Thanks @timtrinidad Actually it seems
archiver@5.3.1requirescrc32-stream@>=4.0.1so we ended up usingresolutionsfield in our monorepo to enforce^4.0.2version:Now everything works.
Ah. In that case, I would do a
yarn why crc32-streamornpm ls crc32-streamto see which package needs to be updated. AFAIK you needcrc32-stream@>=4.0.2fornode@>15.6.0my error was fixed when running
npm install serverlessand editing the package.json files
and
It now deploys without the error.
Same issue here using node v 20
Facing same issue with Node 18.13.0 and serverless 3.34.0.
I also had the same issue, using Node 16.17.0, I know my framework version is old.
Just upgrading this package did the job.
"serverless-webpack": "^5.9.1",This is my environment configuration.
Your Environment Information --------------------------- Operating System: linux Node Version: 16.17.0 Framework Version: 2.2.0 (local) Plugin Version: 4.0.4 SDK Version: 2.3.2 Components Version: 3.1.4
Thanks for your solution @timtrinidad ! However it does not solve the problem for those not using
serverless-webpackI guessbig oof. Im a 100% sure it worked before closing the ticket. Then I’ll reopen it.