[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploaded file must be a non-empty zip again with Node16 #11118

Open
4 tasks done
Bastczuak opened this issue May 30, 2022 · 28 comments
Open
4 tasks done

Uploaded file must be a non-empty zip again with Node16 #11118

Bastczuak opened this issue May 30, 2022 · 28 comments
Labels

Comments

@Bastczuak
Copy link
Bastczuak commented May 30, 2022

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
@Nicoowr
Copy link
Nicoowr commented Jun 13, 2022

Same here, using Serverless 3.19 and Node 16.15.1

@davidalejandroaguilar
Copy link

Same here:

serverless -v
Framework Core: 3.19.0
Plugin: 6.2.2
SDK: 4.3.2
node -v
v16.15.1

@rohityadav225
Copy link

facing same issue

@pgrzesik
Copy link
Contributor
pgrzesik commented Jun 29, 2022

Hey @rohityadav225 - are you on the latest version of the Framework? What installation method do yo use? Which Node version are you using?

@rohityadav225
Copy link

Hi @pgrzesik Below are the details

npm install -g serverless

Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              16.15.1
     Framework Version:         1.80.0
     Plugin Version:            3.8.1
     SDK Version:               2.3.1
     Components Version:        2.34.9

@pgrzesik
Copy link
Contributor

Based on the output you're on a very old Framework version @rohityadav225

@rohityadav225
Copy link

updating to latest framework version fixed the problem but i see the following warning(s)

npm install --location=global serverless@3.19.0
npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated superagent@7.1.6: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731)

@tobilg
Copy link
tobilg commented Jul 14, 2022

I have the same issue when using serverless-webpack and the following

Environment: darwin, node 16.14.0, framework 3.21.0, plugin 6.2.2, SDK 4.3.2

@Bastczuak
Copy link
Author

@tobilg seems like the authors of the code bases fixed something. I can confirm that this problem is solved forr me (macos) by using the latest version of serverless and latest lts of node. Try to use node 16.16.0 with serverless 3.21.0.

@nyle-mrevel
Copy link

Just so this is in here for those having an issue still I wanted to share how I fixed the issue on my end.

I had to switch back to an earlier version of NodeJS (v14 LTS). I highly recommend using NVM (Node Version Manager) so you can switch back to the newer version.

I also used the latest version of Serverless (v3 at the time) since it claims to have backwards compatibility.

That was it honestly. Not a full intuitive answer as to why, probably something deprecated I'd guess.

@Nicoowr
Copy link
Nicoowr commented Aug 5, 2022

This error is still occurring with the latest versions of Node & Serverless :(

✖ Stack ******* failed to deploy (91s)
Environment: darwin, node 16.16.0, framework 3.21.0 (local), plugin 6.2.2, SDK 4.3.2
Credentials: Local, "default" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
UPDATE_FAILED: ListLambdasVersionsLambdaFunction (AWS::Lambda::Function)
Resource handler returned message: "Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400, Request ID: ...)" 

@tobilg
Copy link
tobilg commented Aug 8, 2022

@Bastczuak this still persists, even with the latest versions:

$ sls -v && node -v 
Framework Core: 3.21.0
Plugin: 6.2.2
SDK: 4.3.2

v16.16.0

Error:

UPDATE_FAILED: ListLambdaFunction (AWS::Lambda::Function)
Resource handler returned message: "Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400, Request ID: 035629c1-4218-4041-9c8b-a2cf3e511f99)"

cc @mnapoli

@Bastczuak
Copy link
Author

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

@Bastczuak Bastczuak reopened this Aug 8, 2022
@Nicoowr
Copy link
Nicoowr commented Aug 8, 2022

@Bastczuak Something very weird happened on my side:

  • First it worked when I upgraded to the new versions (16.16.0/3.21).
  • Then I downgraded to 16.14.0 to be sure it really was this upgrade that made the deploy work. The deploy failed.
  • Finally I upgraded again to 16.16.0, but the deploy didn't work anymore

@mnapoli
Copy link
Contributor
mnapoli commented Aug 15, 2022

Hey everyone, I'm trying to reproduce it but can't (all works fine). Though I have Node 18.3.0, has anyone tried upgrading to a higher major Node version? Given the last comment, it seems it's not consistent with the Node version, so that might be something else.

If you use any plugins please list them as well, that could help!

@mnapoli mnapoli added the bug label Aug 15, 2022
@crash7
Copy link
Contributor
crash7 commented Aug 23, 2022

@mnapoli I can reproduce this with node 16.15 - no plugins, last serverless version

@timtrinidad
Copy link
timtrinidad commented Aug 25, 2022

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):
archiverjs/node-archiver#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.

@Nicoowr
Copy link
Nicoowr commented Aug 25, 2022

Thanks for your solution @timtrinidad !
However it does not solve the problem for those not using serverless-webpack I guess

@timtrinidad
Copy link
timtrinidad commented Aug 25, 2022

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

@Nicoowr
Copy link
Nicoowr commented Sep 2, 2022

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.

@orlin7
Copy link
orlin7 commented Sep 8, 2022

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

@arcanereinz
Copy link
arcanereinz commented Nov 2, 2022

I'm using serverless with next.js and named the sls project the same name as the directory:

#!/bin/bash

# current folder name
PRJ=`pwd | rev | cut -d '/' -f 1 | rev`
# zip file name
ZIP=$PRJ.zip

echo ==============================================
echo Serverless fails to package zip file correctly
echo Patching $ZIP
echo ==============================================

cd $PRJ
sls package
cd .serverless
unzip $ZIP -d output
rm $ZIP
cd output
zip -r ../$ZIP *
cd ..
rm -rf output
SHA=`shasum -a 256 $ZIP | cut -d ' ' -f1 | xxd -r -p |base64`
sed -i.old "s#\"CodeSha256\": \"[^\"]*\"#\"CodeSha256\":\"${SHA}\"#g" *.json
rm *.old
cd ..
sls deploy --package .serverless

@Aadil151
Copy link
Aadil151 commented Dec 23, 2022

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.

@sushil-akkawar
Copy link

Facing same issue with Node 18.13.0 and serverless 3.34.0.

@clptrinh
Copy link
clptrinh commented Sep 14, 2023

@sushil-akkawar

Facing same issue with Node 18.13.0 and serverless 3.34.0.

I used "npm update" to update all dependencies and it worked for me

@haruharuharuby
Copy link
Contributor
haruharuharuby commented Oct 19, 2023

if you use serverless-webpack, It would be good to try updating to the latest version (5.13.0).
The conbination between serverless-webpack 5.3.0 and node 18.15.0 did not work in my environment.

several while in debugging, I found that the reason was that appending buffered data to the zip file was failure.

There are a lot of updates on that part in the 5.13.0.
In my local environment, totally worked well.

Running "serverless" from node_modules
Framework Core: 3.35.2 (local) 3.30.1 (global)
Plugin: 7.0.5
SDK: 4.4.0

@juztinlazaro
Copy link

Hi i'm having issue

node 18.12
"serverless-webpack": "5.3.0",
"serverless": "3.36.0",
"serverless-offline-ssm": "^6.2.0",
"serverless-offline": "13.2.1",

Environment: linux, node 18.12.1, framework 3.36.0 (local), plugin 7.1.0, SDK 4.4.0
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

image

@mvergaray
Copy link

Same issue here using node v 20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests