2

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!

Smlok
  • 598
  • 6
  • 19
  • Show us Cloudwatch logs. – Richard Rublev Feb 04 '20 at 06:47
  • Just updated my post, hope it helps! – Smlok Feb 04 '20 at 07:13
  • make sure your local node & npm version matches AWS lambda node version. – matesio Feb 04 '20 at 07:45
  • Thanks for the suggestion - local node version matches AWS Lambda's, but where do I check Lambda's npm version? – Smlok Feb 04 '20 at 07:55
  • I found a little more about the error when installing serverless dashboard. It says that the problem is with a "missing ( after argument list" is in this file: /var/task/serverless_sdk/index.js, however, that file is not in on my local drive. Is it a bug or am I missing something? – Smlok Feb 04 '20 at 09:17

2 Answers2

1

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.

cinerama
  • 47
  • 9
0

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