-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sentry import failing on AWS λ for v7 & v8.7.0 #12322
Comments
Hi @SidPrak7 thanks for writing in! Our layer auto init script is currently only exported for CJS which is why you're running into these errors with your function which is running in ESM. I'm gonna take a look at adding an ESM entry point for this. Can't promise that this will work easily because ESM is a mess but I'll leave an update or PR later. |
try: |
So, I looked into emitting an ESM version of the lambda layer a bit today and as expected it wasn't as straight forward as I hoped 🥲 Some challenges we overcame or still need to figure out:
I'll work on this a bit more tomorrow. For now, to unblock you, I can't give you a better workaround yet than to run your lambdas in CJS ("require") mode. If you're building/transpiling your functions (e.g. typescript) this shouldn't be too hard; otherwise rewriting everything to require instead of import is obviously not ideal. I'll keep you posted on updates. EDIT: Actually, one thing I haven't tried so far is to directly import and use the |
Hi, I have the same issue, tried multiple options as described. |
@tgdn I think this is a different problem than the one described in this issue (which is about running the lambda layer in ESM mode). if you run your lambda function as CJS (i.e. |
@Lms24 I didn't mention it but I'm also running the lambda layer in ESM mode :) The only alternative seems to be importing Sentry and using |
Having the same issue on v8.23.0.
|
Hey @zolbayars thanks for writing in! A lot has changed since this issue was originally reported, including that we finally updated our docs for AWS Lambda. I might be wrong but from the logs, it looks like you're using the Lambda layer in an ESM lambda function. Is this correct? This unfortunately isn't possible at the moment due to some technical limitations we discovered while working on #12409. I recommend going through the docs and choosing the installation method that suits you best. If you're already doing that, can you please open a new issue with more details (ESM or CJS, layer or NPM package, how to reproduce)? Thanks! I'm gonna close this issue for the time being to avoid further mixups. |
Thanks for the reply @Lms24, Somehow I'm not able to create an issue (It says I'm trying to use Sentry on an AWS Lambda written in Typescript. Here's my
According to this doc:
So I have followed the CommonJS instructions. It works fine when I only add the
But when I add profiling, it starts to throw an error:
The error:
|
@zolbayars before we extract this to a new issue, there was a very similar issue recently for profiling node on AWS lambda which was caused by |
Hey @Lms24, yep, I took a look at the issue. But I'm not sure how I could do these 2 steps on
|
|
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/aws-serverless
SDK Version
8.7.0
Framework Version
@sentry/aws-serverless
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
We tried the full combination set of these steps.
We tried these two ARNs
arn:aws:lambda:us-west-2:943013980633:layer:SentryNodeServerlessSDK:247
arn:aws:lambda:us-west-2:943013980633:layer:SentryNodeServerlessSDKv7:1
We also manually built a layer and pushed it to the λ
We tried these env vars
SENTRY_DSN='SENTRY_DSN'
SENTRY_TRACES_SAMPLE_RATE=1
These four variations of
NODE_OPTIONS
:NODE_OPTIONS='-r @sentry/serverless/dist/awslambda-auto'
NODE_OPTIONS='-r @sentry/serverless/awslambda-auto'
NODE_OPTIONS='-r @sentry/aws-serverless/build/npm/cjs/awslambda-auto'
not setting NODE_OPTIONS
It might be relevant that our file is
.mjs
file.We are only noting the relevant errors in the Actual Result section.
Expected Result
Sentry logs something.
Actual Result
For the v7 arn & node options with dist in it:
For the v7 arn & node options without dist in it:
For the arn we got from the docs & node options with
dist
in it:For the arn we got from the docs & node options without
dist
in it:For the arn we got from the docs & node options with
cjs
in it:Also, since the official docs for loading the layer didn't specify setting NODE_OPTIONS, we also tried that:
The text was updated successfully, but these errors were encountered: