Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

__dirname is not defined in ES module scope error when setting up profiling for Remix #217

Open
@jackie-greenbaum

Description

@jackie-greenbaum

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

Screenshot 2023-12-06 at 2 30 20 PM

Below is my code for setting up @sentry/remix in my entry.server.ts file.

 import * as SentryRemix from "@sentry/remix"

 SentryRemix.init({
   dsn: "omitted",
   tracesSampleRate: 1,
   profilesSampleRate: 1,
   integrations: [
     new SentryRemix.Integrations.LocalVariables({
       captureAllExceptions: true,
     }),
     new ProfilingIntegration()
   ],
 })

Expected Result

Profiling works correctly

Actual Result

When I deploy this, I see the following 500 error

2023-12-06T19:44:49.312Z	undefined	ERROR	Uncaught Exception 	
{
    "errorType": "ReferenceError",
    "errorMessage": "__dirname is not defined in ES module scope",
    "stack": [
        "ReferenceError: __dirname is not defined in ES module scope",
        "    at node_modules/@sentry/profiling-node/lib/index.js (file:///var/task/ui/build/index.mjs:48006:777)",
        "    at file:///var/task/ui/build/index.mjs:26:50",
        "    at file:///var/task/ui/build/index.mjs:108280:37"
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions