-
-
Notifications
You must be signed in to change notification settings - Fork 9
__dirname is not defined in ES module scope
error when setting up profiling for Remix
#217
Comments
@jackie-greenbaum could you provide us with a small reproducible example by any chance? |
Which Node.js version do you use in your AWS Lambda? |
18.12.0
So, I was able to create a new remix app with sentry from scratch which just runs on localhost and successfully configure profiling. My current guess is that this issue something to do with my AWS configuration |
I think that you are seeing is an issue with the bundling process. You're trying to bundle your application as a ESM application, but use commonjs functionality like __dirname in the same file. I ran the following code with Node 18.12.0
And it works. It seems your error call stack hints towards issues in bundling:
If you want to use a commonjs file in an ESM application, it needs to trigger ESM loader - which triggers the CJS loader in Node.js. Since they're bundled in the same file, it doesn't trigger any loader. If you're using ESBuild or a similar bundler, you need add
|
HI, I work with @jackie-greenbaum . Marking I do vaguely recall other issues with node builtins that needed to be polyfilled but I haven't been able to track down the issues/discussions I was looking at. It may have been back when we were trying to bundle this as CommonJS, or maybe I'm misremembering things. @jackie-greenbaum Were you testing the minimal repro app with |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
SDK Version
7.81.1
Link to Sentry event
N/A
What environment is your node script running in?
Remix 2.1.0
How is your code deployed and bundled?
Remix running in AWS Lambda
Steps to Reproduce
Followed the steps to set up my Remix application with profiling as described by the sidebar that appears when clicking
Set up Profiling
Below is my code for setting up
@sentry/remix
in myentry.server.ts
file.Expected Result
Profiling works correctly
Actual Result
When I deploy this, I see the following 500 error
The text was updated successfully, but these errors were encountered: