Smlok
Smlok

Reputation: 658

Deploying a serverless next.js react app to AWS Lambda, getting {"message": "Internal server error"}

I have been trying to deploy a simple serverless React.js Next app to AWS Lambda. Everything looks fine when deploying the app in Node.js and in AWS CloudFormation status is a green UPDATE_COMPLETE.

However, when I visit the endpoint link I get

{"message": "Internal server error"}

Needless to say, I am new to this and just trying to get my first app with the Serverless app running. This is the tutorial I followed: https://statsbot.co/blog/a-crash-course-on-serverless-side-rendering-with-reactjs-nextjs-and-aws-lambda/, but I disabled the serverless-domain-manager because I'm fine with any given domain, I just want to get a super basic React Next app work first and then think about more complicated steps.

I checked in more detail about the error in CloudWatch and here is what it returned me: 2020-02-04T05:21:27.230Z undefined ERROR Uncaught Exception

{
    "errorType": "Runtime.UserCodeSyntaxError",
    "errorMessage": "SyntaxError: missing ) after argument list",
    "stack": [
        "Runtime.UserCodeSyntaxError: SyntaxError: missing ) after argument list",
        "    at _loadUserApp (/var/runtime/UserFunction.js:98:13)",
        "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
        "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:956:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)",
        "    at Module.load (internal/modules/cjs/loader.js:812:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:724:14)",
        "    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)",
        "    at internal/main/run_main_module.js:17:11"
    ]
}

and it ends with this: Unknown application error occurred Runtime.UserCodeSyntaxError

Unknown application error occurred
Runtime.UserCodeSyntaxError

As far as I understand IAM role is configured correctly since all uploaded to AWS correctly.

I hope I can receive some help on this issue. Many thanks!

Upvotes: 2

Views: 3023

Answers (2)

cinerama
cinerama

Reputation: 57

I got the same error message {"message": "Internal server error"} when testing my lambda app using the api-gateway as my endpoint. I found the answer here: https://aws.amazon.com/premiumsupport/knowledge-center/malformed-502-api-gateway/

In my case I had to restructure the mysql query to output the body in JSON format, hope this helps you.

Upvotes: 1

jckmrrssy
jckmrrssy

Reputation: 1

I was running into the same problem. I think it's because Lambda doesn't support ES6 import statements, as described here

Upvotes: 0

Related Questions