简体   繁体   中英

How do I get full logs out of aws lambda invoke?

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?

我有一个类似的问题,我的问题最终是在我的项目不支持时导入使用 ESM 的包。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM