Skip to content

@sentry/remix doesn't work with Node ESM support #8474

Closed
@tmcw

Description

@tmcw

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/remix

SDK Version

7.55.2

Framework Version

1.18.1

Link to Sentry event

No response

SDK Setup

This is reproducible without setup

Steps to Reproduce

Create a file:

import * as Sentry from "@sentry/remix"

console.log(Sentry);

You would expect the Sentry object to contain methods like captureEvent

Expected Result

It doesn't. The import to @sentry/node under the hood fails to pull named exports and instead you get a default object under the exports that contains all of the event-capturing methods. This makes the included TypeScript types incorrect and makes a line like

Sentry.captureException(e);

Fail because the method is actually at

Sentry.default.captureException(e);

But in a typescript environment, you can't write the latter because the types say that captureEvent is a named export, not nested under a default object.

Actual Result

[Module: null prototype] {
  ErrorBoundary: [class ErrorBoundary extends Component],
  __esModule: true,
  default: {
    ErrorBoundary: [class ErrorBoundary extends Component],
    withErrorBoundary: [Function: withErrorBoundary],
    remixRouterInstrumentation: [Function: remixRouterInstrumentation],
    withSentry: [Function: withSentry],
    wrapExpressCreateRequestHandler: [Function: wrapExpressCreateRequestHandler],
    init: [Function: init],
    Hub: [class Hub],
    SDK_VERSION: '7.55.2',
    Scope: [class Scope],
    addBreadcrumb: [Function: addBreadcrumb],
    addGlobalEventProcessor: [Function: addGlobalEventProcessor],
    captureCheckIn: [Function: captureCheckIn],
    captureEvent: [Function: captureEvent],
    captureException: [Function: captureException],
    captureMessage: [Function: captureMessage],
    configureScope: [Function: configureScope],
    createTransport: [Function: createTransport],
    extractTraceparentData: [Function: extractTraceparentData],
    getActiveTransaction: [Function: getActiveTransaction],
    getCurrentHub: [Function: getCurrentHub],
    getHubFromCarrier: [Function: getHubFromCarrier],
    makeMain: [Function: makeMain],
    runWithAsyncContext: [Function: runWithAsyncContext],
    setContext: [Function: setContext],
    setExtra: [Function: setExtra],
    setExtras: [Function: setExtras],
    setTag: [Function: setTag],
    setTags: [Function: setTags],
    setUser: [Function: setUser],
    spanStatusfromHttpCode: [Function: spanStatusfromHttpCode],
    startTransaction: [Function: startTransaction],
    trace: [Function: trace],
    withScope: [Function: withScope],
    autoDiscoverNodePerformanceMonitoringIntegrations: [Function: autoDiscoverNodePerformanceMonitoringIntegrations],
    NodeClient: [class NodeClient extends BaseClient],
    makeNodeTransport: [Function: makeNodeTransport],
    close: [AsyncFunction: close],
    defaultIntegrations: [
      [InboundFilters],
      [FunctionToString],
      [Console],
      [Http],
      [Undici],
      [OnUncaughtException],
      [OnUnhandledRejection],
      [ContextLines],
      [LocalVariables],
      [Context],
      [Modules],
      [RequestData],
      [LinkedErrors]
    ],
    defaultStackParser: [Function (anonymous)],
    flush: [AsyncFunction: flush],
    getSentryRelease: [Function: getSentryRelease],
    lastEventId: [Function: lastEventId],
    DEFAULT_USER_INCLUDES: [ 'id', 'username', 'email' ],
    addRequestDataToEvent: [Function: addRequestDataToEvent],
    extractRequestData: [Function: extractRequestData],
    deepReadDirSync: [Function: deepReadDirSync],
    Handlers: {
      extractRequestData: [Function: extractRequestData],
      parseRequest: [Function: parseRequest],
      errorHandler: [Function: errorHandler],
      requestHandler: [Function: requestHandler],
      tracingHandler: [Function: tracingHandler],
      trpcMiddleware: [Function: trpcMiddleware]
    },
    Integrations: {
      FunctionToString: [Function],
      InboundFilters: [Function],
      Console: [Function],
      Http: [Function],
      OnUncaughtException: [Function],
      OnUnhandledRejection: [Function],
      LinkedErrors: [Function],
      Modules: [Function],
      ContextLines: [Function],
      Context: [Function],
      RequestData: [Function],
      LocalVariables: [Function],
      Undici: [Function],
      Apollo: [Function],
      Express: [Function],
      GraphQL: [Function],
      Mongo: [Function],
      Mysql: [Function],
      Postgres: [Function],
      Prisma: [Function]
    }
  },
  init: [Function: init],
  remixRouterInstrumentation: [Function: remixRouterInstrumentation],
  withErrorBoundary: [Function: withErrorBoundary],
  withSentry: [Function: withSentry],
  wrapExpressCreateRequestHandler: [Function: wrapExpressCreateRequestHandler]
}

Metadata

Metadata

Assignees

Labels

Package: remixIssues related to the Sentry Remix SDK

Type

No type

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions