aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

How to access /var/runtime/UserFunction.js?

Open dz902 opened this issue 5 years ago • 7 comments

Describe your idea/feature/enhancement

I got a mystic error (await needs to be in async) but error only traces back to UserFunction.js, how can I access this file so I can locate the exact problem?

Proposal

Show how it is done, and probably add a section in document.

Thanks!

dz902 avatar Dec 16 '19 05:12 dz902

Thanks for the Report! Can you be more specific about you are trying to do, and what led to this error?

sriram-mv avatar Dec 18 '19 21:12 sriram-mv

I got an error await can only be used in async function, but the error message in console only traces back to a line in /var/runtime/UserFunction.js, but it is not the file name I used in my code.

I had to remove code piece by piece and finally found the problem. If I could just open that file, which I presumed is generated by SAM, then the error will be prominent.

I occasionally run into such errors without clear indication of the source file, so I wonder whether we can have some access to the generated UserFunction.js in some way.

Hope that's clear. Thanks!

dz902 avatar Dec 20 '19 04:12 dz902

Closing as issue seems to be resolved from above comment.

CoshUS avatar Nov 28 '20 01:11 CoshUS

I want to follow up on this and try to get the same answer that the OP asked: the logging stack is impossible to understand without access to userFunction.js, and I have big lambda functions. Can we access it?

The error I'm getting is happening in the transpilation step (from TS -> JS via Webpack / Babel), this makes it very tricky to understand what's going wrong, because none of the pre-transpiled code current has any syntax errors like this one:

stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '.'"," at _loadUserApp (/var/runtime/UserFunction.js:98:13)","

tommyyork avatar Jan 20 '21 09:01 tommyyork

I want to follow up on this and try to get the same answer that the OP asked: the logging stack is impossible to understand without access to userFunction.js, and I have big lambda functions. Can we access it?

The error I'm getting is happening in the transpilation step (from TS -> JS via Webpack / Babel), this makes it very tricky to understand what's going wrong, because none of the pre-transpiled code current has any syntax errors like this one:

stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '.'"," at _loadUserApp (/var/runtime/UserFunction.js:98:13)","

Did you solve it? I have similar issue with same stack.

amouly avatar Mar 31 '21 03:03 amouly

@amouly Did you ever solve this problem? I am getting the same issue in the same file

faridg18 avatar Oct 14 '21 04:10 faridg18

Same problem here. Why is this closed? This is making debugging very difficult

daamsie avatar Nov 23 '21 22:11 daamsie

UserFunction.js is a provided file within the Lambda Execution Environment. It comes up in debugging because it is what ends up executing your code.

This is not publicly documented, but you can see this file through running the docker container locally with a shell and cating the file.

jfuss avatar Dec 08 '22 19:12 jfuss

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Dec 08 '22 19:12 github-actions[bot]