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

Unable to deploy to Serverless due to 'empty zip' #8794

Closed
ghost opened this issue Jan 20, 2021 · 27 comments
Closed

Unable to deploy to Serverless due to 'empty zip' #8794

ghost opened this issue Jan 20, 2021 · 27 comments

Comments

@ghost
Copy link

ghost commented Jan 20, 2021

I have a GraphQL API that has two indexes, one runs Express (index.js) and the other runs Serverless (indexServerless.js). For the Serverless I use serverless-offline to test the API out of Serverless. I tested both Express and Serverless locally and both of them are working. If I try to deploy to Serverless through serverless login and serverless deploy I receive the following message from Serverless CLI:

An error occurred: GraphqlLambdaFunction - Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException

And this one from Cloudformation:

UPDATE_COMPLETE
UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS
UPDATE_ROLLBACK_COMPLETE

Which is strange cause I have not changed the API since the last deploy so I contacted Serverless support but they throw GraphQL into the conversation and told me that they could not help me, any idea on how to fix it?

Here's the serverless.yml:

org: X

app: X

service: X

provider:
  name: aws
  runtime: nodejs12.x
  stage: production # development
  region: eu-central-1

plugins:
  - serverless-offline

functions:
  graphql:
    handler: indexServerless.graphqlServerless
    timeout: 20
    events:
      - http:
          path: graphql
          method: post
          cors: true

The indexServerless.js:

const { graphqlServerless } = require("./graphql");

require("dotenv").config();

module.exports.graphqlServerless = graphqlServerless;

And the graphql.js, which export both configurations, i.e Express and Serverless:

// Apollo serverless
const graphqlServerless = new ApolloServerless({
  typeDefs,
  resolvers,
  cors: false,
  playground: {
    endpoint: "/dev/graphql",
  },
  introspection: false,
  debug: false,
  mocks: false,
  schemaDirectives: {
    auth: directives.AuthDirective,
    guest: directives.GuestDirective,
  },
  context: ({ event, context }) => {
    return {
      headers: event.headers,
      functionName: context.functionName,
      event,
      context,
    };
  },
});

module.exports = {
  graphqlServer, // Express
  graphqlServerless: graphqlServerless.createHandler({
    cors: {
      origin: process.env.GRAPHQL_CORS_SERVERLESS, // true
      credentials: true,
    },
  }), // Serverless
};

I tried to exclude node_modules by setting exclude on serverless.yml and update the Node version, but no changes.

Here's the Serverless CLI version:

Framework Core: 2.19.0
Plugin: 4.4.2
SDK: 2.3.2
Components: 3.4.7

And the Node dependencies:

{
    "apollo-server-express": "^2.19.2",
    "apollo-server-lambda": "^2.19.2"
}
@ghost
Copy link
Author

ghost commented Jan 20, 2021

Update: I received another message from the support telling me to create this issue cause it looks like to be a bug in Serverless, I made one yesterday in Apollo Lambda repo apollographql/apollo-server#4856

image

@thuringia
Copy link

I can confirm this from a project without usages of Apollo:

  Serverless Error ---------------------------------------

  An error occurred: NoopLambdaFunction - Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: f1dc6c61-c57e-4580-981e-9d41ffecd12c; Proxy: null).

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              15.6.0
     Framework Version:         2.17.0 (local)
     Plugin Version:            4.4.1
     SDK Version:               2.3.2
     Components Version:        3.4.3

This happens regardless of the version of serverless, so this might be an AWS issue or outage.

@ghost
Copy link
Author

ghost commented Jan 20, 2021

I can confirm this from a project without usages of Apollo:

  Serverless Error ---------------------------------------

  An error occurred: NoopLambdaFunction - Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: f1dc6c61-c57e-4580-981e-9d41ffecd12c; Proxy: null).

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              15.6.0
     Framework Version:         2.17.0 (local)
     Plugin Version:            4.4.1
     SDK Version:               2.3.2
     Components Version:        3.4.3

This happens regardless of the version of serverless, so this might be an AWS issue or outage.

Yeah. I'm using Cloudformation, S3, and Lambda along with Serverless

@pgrzesik
Copy link
Contributor

Hello @sphinxs - thanks for reporting. Looking at your report it seems like you might be using node v15.6.0 - there's a known issue that is caused by one of our deps not working properly on that version: #8772

Would you be able to downgrade and check if the issue persist?

@Bumbleblo
Copy link

Bumbleblo commented Jan 20, 2021

Hello @sphinxs - thanks for reporting. Looking at your report it seems like you might be using node v15.6.0 - there's a known issue that is caused by one of our deps not working properly on that version: #8772

Would you be able to downgrade and check if the issue persist?

I successfully deployed the aws-python3 template using node image (14.15.4-buster). With the image 15.6.0-buster I have the same problem.

@ghost
Copy link
Author

ghost commented Jan 21, 2021

Yeah, Node version was the problem.

Here's a quick script that I made if anyone needs it:

sudo npm install -g n # Install N

sudo n 14.15.4 # Install a specific version of Node

# n run 14.15.4 index.js # Run a script without change the global path

# n which 14.15.4 # Search the path of the installed Node

n 14.15.4 # Set the installed Node as global, requires the terminal to be restarted

serverless deploy

@ghost
Copy link
Author

ghost commented Jan 21, 2021

Hello ( : and thanks @pgrzesik and @Bumbleblo

@ghost
Copy link
Author

ghost commented Jan 21, 2021

I hope that it supports Node 15 as soon as possible, once security failures were found in previous versions...

@v1shva
Copy link

v1shva commented Jan 21, 2021

Downgrading the to node version 14.15.4 worked for me.

@pgrzesik
Copy link
Contributor

Thanks for confirming that 🙇 Would you be okay with closing this issue and tracking everything via the one I linked?

@RTC1
Copy link

RTC1 commented Jan 21, 2021

Confirmed solution by @sphinxs .

@Saisreenivas
Copy link

Hello & Thanks.., Downgrading the node version to 14.15.4 worked for me too.

@eliyasmeth
Copy link

I got the same issue yesterday. Thanks and confirmed with the downgrade to 14.15.4 works fine.

@ghost
Copy link
Author

ghost commented Jan 21, 2021

Closed

@mathieubrunpicard
Copy link

Got the same issue and downgrading to 14.15.4 worked for me as well

@mmehira
Copy link

mmehira commented May 25, 2021

Same error on Ubuntu 20.04 using 16.2.0 node version.

Downgrade to 15.3.0 and now everything is working.

@nicovigil1
Copy link

^^ the above worked for me as well

@mdrijwan
Copy link

Yeah, Node version was the problem.

Here's a quick script that I made if anyone needs it:

sudo npm install -g n # Install N

sudo n 14.15.4 # Install a specific version of Node

# n run 14.15.4 index.js # Run a script without change the global path

# n which 14.15.4 # Search the path of the installed Node

n 14.15.4 # Set the installed Node as global, requires the terminal to be restarted

serverless deploy

excellent! this worked man!

@mannharleen
Copy link

As of October 2021, the above solution is still valid.

@KalanaPerera
Copy link

NODE 16.09.1 have same problem

@pgrzesik
Copy link
Contributor

pgrzesik commented Dec 6, 2021

@KalanaPerera What version of the Framework are you using? Please reinstall the Framework to ensure all dependencies are also upgraded

@KalanaPerera
Copy link

@KalanaPerera What version of the Framework are you using? Please reinstall the Framework to ensure all dependencies are also upgraded

Used version: 2.16.1

After downgrading NODE to 15.5.1 worked fine.

Thank you for quick reply.

@pgrzesik
Copy link
Contributor

pgrzesik commented Dec 6, 2021

@KalanaPerera You're using a bit outdated version of the Framework - upgrade to the newest version should help as well

@camranhansen
Copy link

I have also experienced this issue with node v16.15.0, downgrading to v14.15.4 resolved it.

@pgrzesik
Copy link
Contributor

pgrzesik commented May 8, 2022

@camranhansen What version of Framework were you using? All new version of the Framework should not run into this bug, doesn't matter what Node version they're using

@camranhansen
Copy link

@pgrzesik Yeah, I think that my Serverless version was the real issue here. Upgraded to 3.17 and a few issues have actually been fixed, including something with graphQL schema validation. Thank you for the suggestion.

@pgrzesik
Copy link
Contributor

Great to hear you've been able to resolve this issue 🎉

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

No branches or pull requests