最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - How do I get full logs out of aws lambda invoke? - Stack Overflow

matteradmin7PV0评论

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._pile (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?

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._pile (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?

Share Improve this question edited Jul 2, 2019 at 1:37 jcollum asked Jun 30, 2019 at 23:25 jcollumjcollum 46.7k63 gold badges211 silver badges345 bronze badges 0
Add a ment  | 

4 Answers 4

Reset to default 3

I had a similar issue and my problem ended up being around importing a package that uses ESM when my project didn't support that.

I had a similar issue with AWS amplify function.

My problem caused by import syntax(ES2015). I use require syntax(node) instead of import syntax. And it works.

SyntaxError: Unexpected identifier","stack":

Says that the error is in your function code. Your using the "identifier" stack and it hadn't been declared mabe?

I've never used AWS lambda but, Runtime.UserCodeSyntaxError, sounds like the function encountered a runtime error ( during code execution ) related to the syntax of your code.

I didn't have experience with Python. But I had it with Java. In Java lambda function, I catch any exceptions and use e.printstackTrace() in the catch. The output goes to CloudWatch automatically

Post a comment

comment list (0)

  1. No comments so far