Repository navigation
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/aws-serverless
SDK Version
8.2.1
Framework Version
No response
Link to Sentry event
No response
SDK Setup
No response
Steps to Reproduce
Load the lambda layer 243 and initialize as documented -r @sentry/aws-serverless/awslambda-auto
Expected Result
Sentry is imported and initialized as expected
Actual Result
Error: Expected Module._resolveFilename to be a function (was: undefined) - aborting!
--
Please report this error as an issue related to Node.js v16.20.2 at https://github.com/elastic/require-in-the-middle/issues
/opt/nodejs/node_modules/@sentry/aws-serverless/build/npm/cjs/index-BL-xGqAo.js:2
var t=require("perf_hooks"),n=require("path"),e=require("util"),r=require("module"),o=require("fs"),i=require("os"),s=require("tty"),c=require("url"),u=require("process"),a=require("child_process"),l=require("events"),d=require("worker_threads"),f=require("inspector"),h=require("http"),p=require("node:http"),S=require("node:https"),E=require("stream"),T=require("zlib"),m=require("net"),_=require("tls"),b=require("async_hooks"),v="undefined"!=typeof document?document.currentScript:null;function R(t){var n=Object.create(null);return t&&Object.keys(t).forEach((function(e){if("default"!==e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}})),n.default=t,Object.freeze(n)}function y(t
INIT_REPORT Init Duration: 255.94 ms Phase: init Status: error Error Type: Runtime.ExitError
Error: Expected Module._resolveFilename to be a function (was: undefined) - aborting!
Please report this error as an issue related to Node.js v16.20.2 at https://github.com/elastic/require-in-the-middle/issues
/opt/nodejs/node_modules/@sentry/aws-serverless/build/npm/cjs/index-BL-xGqAo.js:2
Metadata
Metadata
Assignees
Labels
No labels
Projects
- StatusShow more project fieldsNo status
Activity
Lms24 commentedon May 16, 2024
Hey @JoaquinFernandez thanks for reporting (again)! We'll look into this tomorrow. Sorry for the prolonged trouble
Lms24 commentedon May 17, 2024
Quick update: We tracked this down to a build issue with the lambda layer specifically. We're currently investigating how to fix it.
As a workaround (while definitely not optimal), you can set up the SDK via an NPM package instead of the layer. I just tested this locally and on AWS
and this seems to work. Again, we recognize this is far from ideal for current layer users. We're on the fix right now.
Lms24 commentedon May 17, 2024
Update before the weekend:
We're still not sure what exactly is broken; lest how to fix that but we narrowed it down a bit. I'm gonna document my findings here for some more context and I'll pick this up on Tuesday again (Monday is a holiday here 🙃).
Workarounds
We fully recognize this is not ideal but there are two workarounds:
Using v7 of the Lambda layer
We just re-published the most recent v7 version of our AWS lambda layer. It got a new name (which is why the number starts at 1 again) but apart from that it can be used exactly like the layer up to version 235.
NODE_OPTIONSenv variable is set up for v7Using v8 via the
@sentry/aws-serverlessNPM packageYou can also use the
@sentry/aws-serverlessSDK directly as an NPM package/dependency and callSentry.initin your lambda code. Follow the docs for this approach. Please make sure the require call andSentry.initare the first two lines of code in your lambda function.Findings
Here's what we know so far:
@sentry/aws-serverless) into oneindex.jsfile (which is called fromawslambda-auto.jswhen automatically initializing the SDK via the-rnode option.-rargument OR by requiring@sentry/aws-serverlessand callingSentry.iniin the lambda code both throw the same error (the one posted in the issue description)I know I must sound like a broken record by now but sorry for the prolonged troubles with the Lambda layer. We hope to find a fix soon.
Lms24 commentedon May 27, 2024
Hey @JoaquinFernandez some updates on this:
I opened two PRs today
Module._resolveFilenamein Lambda layer bundle #12232 fixes an issue withrequire-in-the-middlewhich was caused by a bundling errors on our endImportInTheMiddle#12233 temporarily fixes an issue withimport-in-the-middle. We technically don't need this library in the AWS bundle but can't get rid of it easily as it's a dependency of our OpenTelemetry instrumentation. However, it nevertheless threw an error that crashed the lambda function.Once this is released (probably today or tomorrow), the lambda layer should be usable again 🤞
fix(aws): Ensure lambda layer uses default export from `ImportInTheMi…
AbhiPrasad commentedon May 27, 2024
Fixes released with https://github.com/getsentry/sentry-javascript/releases/tag/8.5.0 - please give it a try!
JoaquinFernandez commentedon May 29, 2024
I can confirm it works now. Thank you!