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

Most upvoted comments

tl;dr: Upgrade serverless-webpack

Background 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:

$ 7z l -slt notify.zip | grep -e Path -e CRC
Path = notify.zip
Path = src/circle-mask.png
CRC = 00000000
Path = src/notify-user-handler.js
CRC = 00000000
Path = src/notify-user-handler.js.map
CRC = 00000000

This is confirmed when unzipping:

$ unzip notify.zip 
Archive:  notify.zip
  inflating: src/circle-mask.png      bad CRC ccece94a  (should be 00000000)
  inflating: src/notify-user-handler.js   bad CRC cce37a62  (should be 00000000)
  inflating: src/notify-user-handler.js.map   bad CRC 28afd87b  (should be 00000000)

@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-webpack version is 5.3.1 which is including archiver@2.1.1

Solution When I upgraded serverless-webpack to 5.9.0, it requires archiver@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-stream which was affected by this zlib behavior change in Node v15.6.0.

Thanks @timtrinidad Actually it seems archiver@5.3.1 requires crc32-stream@>=4.0.1 so we ended up using resolutions field in our monorepo to enforce ^4.0.2 version:

  "resolutions": {
    "crc32-stream": "^4.0.2"
  }

Now everything works.

Ah. In that case, I would do a yarn why crc32-stream or npm ls crc32-stream to see which package needs to be updated. AFAIK you need crc32-stream@>=4.0.2 for node@>15.6.0

my error was fixed when running npm install serverless

and editing the package.json files

    "serverless-bundle": "^4.3.1",
    "serverless-dotenv-plugin": "^2.1.1",
    "serverless-offline": "^5.3.3"

and

    "serverless": "^3.26.0",

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-webpack I guess

big oof. Im a 100% sure it worked before closing the ticket. Then I’ll reopen it.