https://serverless-stack.com/ logo
#help
Title
# help
m

Michele

01/13/2022, 3:22 PM
Hello everyone! We have a NextJS website deployed to AWS via sst, our java backend is completely separated from it. It’s the second time in a couple of weeks that we receive warnings from CloudWatch caused by the default NextSiteApiFunction lambda created on deployment by sst. The logs read as follow:
Copy code
{
  "errorType": "Runtime.UserCodeSyntaxError",
  "errorMessage": "SyntaxError: Unexpected token 'export'",
  "stack": [
    "Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token 'export'",
    "    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:999:30)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
    "    at Module.load (internal/modules/cjs/loader.js:863:32)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
    "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
    "    at internal/main/run_main_module.js:17:47"
  ]
}
This burst of errors is limited to a 15 min timespan, before & after the logs are are fine with no other issues reported. We’re not making any use of the
/api
routes in the NextJS project so we don’t need any support for its “backend”. Would you have any tip on how to troubleshoot this issue? Thank you in advance!
The NextSiteApiFunction code is the default one that sst deploys:
Copy code
export async function handler() {
  // placeholder function
}
f

Frank

01/26/2022, 2:35 AM
Hey @Michele sorry for the late follow up, I got it to reproduce on my end.
Just submitted a fix for this. Will make it into the next release https://github.com/serverless-stack/serverless-stack/pull/1302
Hey @Michele this should be fixed in v0.60.5!
m

Michele

01/28/2022, 3:49 PM
Hi @Frank I missed your ping, thanks for looking into it and solving the issue! To upgrade to v0.60.5 - and to upgrade sst in general - should I just change the
@serverless-stack-slack/cli
and
@serverless-stack/resources
version in the package.json file? I tried running
npm update @serverless-stack/cli @serverless-stack/resources
but this only updates the package-lock.json, the version for those packages stays at our current one (v0.53.2) in package.json. Apologies for the naive question, not too knowledgeable in this topic 😅
f

Frank

01/30/2022, 8:51 PM
You can use the
sst update
command, ie.
npx sst update 0.60.5
. With the exception that if you are currently on a version earlier than
0.59.0
, you’d have to follow these steps to update to
0.59.0
first.
m

Michele

01/30/2022, 10:02 PM
Really appreciate all the help given, thank you!
2 Views