First, Cloudwatch logs aren't working for this function. Just get a message about how it failed to create a log stream. But I'm not sure that would help because when I invoke the function:
aws lambda invoke --function-name update-data out \
--payload '{"year": "2013"}' --log-type Tail \
--query 'LogResult' --output text | base64 -D
The stack trace is pretty worthless:
2019-06-30T23:17:31.684Z undefined ERROR Uncaught Exception
{"errorType":"Runtime.UserCodeSyntaxError",
"errorMessage":"SyntaxError: Unexpected identifier","stack":
["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected identifier","
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:36:30)","
at Module._compile (internal/modules/cjs/loader.js:701:30)","
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)","
at Module.load (internal/modules/cjs/loader.js:600:32)","
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)","
at Function.Module._load (internal/modules/cjs/loader.js:531:3)","
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)","
at startup (internal/bootstrap/node.js:283:19)"]}
[mild edits for readability]
The function is running in Node 10. I have a suspicion regarding the actual issue but it would be really helpful in the future if I could figure out a better way to get to the source of the failure.
Is there a way to get to the source of the Unexpected identifier error? Line # and file in my code that caused that error?