Skip to content

TypeError: headers[Symbol.for(...)] is not a function in Remix SDK #6294

@sergiodxa

Description

@sergiodxa

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/remix

SDK Version

7.21.1

Framework Version

1.4.3

Link to Sentry event

No response

Steps to Reproduce

I have setup Sentry Remix SDK as shown in the guide.

This is my Express.js config:

// near the top of the file
let dsn = process.env.FRONTEND_SENTRY_DSN;

const createSentryRequestHandler = dsn
  ? wrapExpressCreateRequestHandler(createRequestHandler)
  : createRequestHandler;

// inside `server.all("*")`
return createSentryRequestHandler({ build: require("./build"), mode: env })(
  req,
  res,
  next
);

In my entry.server.tsx I setup Sentry this way:

import * as Sentry from "@sentry/remix";

// this is outside the handleRequest function but I tried inside too
if (process.env.FRONTEND_SENTRY_DSN) {
  Sentry.init({
    dsn: process.env.FRONTEND_SENTRY_DSN,
    tracesSampleRate: 1,
    integrations: [],
    attachStacktrace: true,
    debug: process.env.NODE_ENV === "development",
  });
}

And in entry.client.tsx, before I hydrate my Remix app

if (process.env.FRONTEND_SENTRY_DSN) {
  Sentry.init({
    dsn: process.env.FRONTEND_SENTRY_DSN,
    tracesSampleRate: 1,
    integrations: [
      new Sentry.BrowserTracing({
        routingInstrumentation: Sentry.remixRouterInstrumentation(
          useEffect,
          useLocation,
          useMatches
        ),
      }),
    ],
    attachStacktrace: true,
    debug: process.env.NODE_ENV === "development",
  });
}

I'm using the same version of Remix installed as devDependency in the SDK source code

"@remix-run/node": "^1.4.3",
"@remix-run/react": "^1.4.3",

And I'm using Node v16 (also tried v18) which match the supported engines

"engines": {
"node": ">=14"
},

Expected Result

It should render my app and work correctly.

Actual Result

I get a white screen with black text with this error

TypeError: headers[Symbol.for(...)] is not a function
    at Object.normalizeRemixRequest (/Users/[REDACTED]/node_modules/@sentry/src/utils/web-fetch.ts:117:1)
    at /Users/[REDACTED]/node_modules/@sentry/src/utils/instrumentServer.ts:379:1
    at bound (node:domain:433:15)
    at runBound (node:domain:444:12)
    at /Users/[REDACTED]/node_modules/@sentry/src/utils/instrumentServer.ts:408:1
    at /Users/[REDACTED]/frontend/node_modules/@remix-run/express/server.js:41:28
    at remixHandler (/Users/[REDACTED]/server/index.js:104:78)
    at Layer.handle [as handle_request] (/Users/[REDACTED]/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/[REDACTED]/node_modules/express/lib/router/route.js:137:13)
    at next (/Users/[REDACTED]/node_modules/express/lib/router/route.js:131:14)

From the stacktrace, and after trying to debug it in node_modules, the error is happening on this exact line

headers: headers[Symbol.for('nodejs.util.inspect.custom')](),
, looks like the symbol Symbol.for('nodejs.util.inspect.custom') is not a key in headers.

If I replace the line with just headers: headers (or just headers) my app renders correctly and when I throw an error it's reported to Sentry too, so I'm not sure what that line does, and from the comment who coded it doesn't know too 😅

Metadata

Metadata

Assignees

Labels

Package: remixIssues related to the Sentry Remix SDK

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions