wrapExpressCreateRequestHandler not working in Remix with Express adapter
See original GitHub issueIs 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 package are you using?
SDK Version
7.12.1
Framework Version
Remix 1.7.0
Link to Sentry event
No response
Steps to Reproduce
- Create new Remix app (with custom Express server and TypeScript):
$ npx create-remix@latest
Need to install the following packages:
create-remix@latest
Ok to proceed? (y) y
? Where would you like to create your app? remix-express
? What type of app do you want to create? Just the basics
? Where do you want to deploy? Choose Remix App Server if you're unsure; it's easy to change deployment
targets. Express Server
? TypeScript or JavaScript? TypeScript
- Install @sentry/remix:
npm install @sentry/remix
-
Configure Sentry according to the official documentation. Enable Sentry debug logging in
entry.server.tsx
for good measure. -
Throw an error from any loader, start the app (either dev or prod would do) and open the corresponding route in a browser.
Expected Result
The thrown error should be sent to sentry.io and appear in the Web UI.
Actual Result
No error is sent to sentry.io and no Sentry activity is logged:
$ npm run dev
> dev
> remix build && run-p "dev:*"
Building Remix app in production mode...
Built in 205ms
> dev:node
> cross-env NODE_ENV=development nodemon ./server.js --watch ./server.js
> dev:remix
> remix watch
[nodemon] 2.0.19
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): server.js
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./server.js`
Express server listening on port 3000
Watching Remix app in development mode...
💿 Built in 389ms
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: Context
There was an error running the data loader for route routes/error
Error: Fehler!!!
at loader (/path/to/remix-express/app/routes/error.tsx:6:11)
at /path/to/remix-express/node_modules/@sentry/remix/cjs/utils/instrumentServer.js:123:21
at Object.callRouteLoader (/path/to/remix-express/node_modules/@remix-run/server-runtime/dist/data.js:77:20)
at /path/to/remix-express/node_modules/@remix-run/server-runtime/dist/server.js:261:113
at Array.map (<anonymous>)
at handleDocumentRequest (/path/to/remix-express/node_modules/@remix-run/server-runtime/dist/server.js:261:67)
at requestHandler (/path/to/remix-express/node_modules/@remix-run/server-runtime/dist/server.js:49:24)
at /path/to/remix-express/node_modules/@sentry/remix/cjs/utils/instrumentServer.js:330:35
at bound (node:domain:421:15)
at runBound (node:domain:432:12)
GET /error 500 - - 74.239 ms
This started happening with the introduction of wrapExpressCreateRequestHandler
in 7.11.0. Following the above-mentioned steps with 7.10.0 (minus wrapping createRquestHandler
with wrapExpressCreateRequestHandler
) would correctly send the error to sentry.io:
$ npm run dev
> dev
> remix build && run-p "dev:*"
Building Remix app in production mode...
Built in 169ms
> dev:node
> cross-env NODE_ENV=development nodemon ./server.js --watch ./server.js
> dev:remix
> remix watch
[nodemon] 2.0.19
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): server.js
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./server.js`
Express server listening on port 3000
Watching Remix app in development mode...
💿 Built in 177ms
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: [Tracing] Starting 'remix.server.loader' span on transaction 'routes/error' (a2516edfe3d1ab7c).
There was an error running the data loader for route routes/error
Sentry Logger [log]: [Tracing] Starting 'remix.server.documentRequest' span on transaction 'routes/error' (a2516edfe3d1ab7c).
Error: Fehler!!!
at loader (/path/to/remix-express/app/routes/error.tsx:6:11)
at /path/to/remix-express/node_modules/@sentry/remix/cjs/utils/instrumentServer.js:140:26
at Object.callRouteLoader (/path/to/remix-express/node_modules/@remix-run/server-runtime/dist/data.js:77:20)
at /path/to/remix-express/node_modules/@remix-run/server-runtime/dist/server.js:261:113
at Array.map (<anonymous>)
at handleDocumentRequest (/path/to/remix-express/node_modules/@remix-run/server-runtime/dist/server.js:261:67)
at requestHandler (/path/to/remix-express/node_modules/@remix-run/server-runtime/dist/server.js:49:24)
at /path/to/remix-express/node_modules/@sentry/remix/cjs/utils/instrumentServer.js:288:41
at /path/to/remix-express/node_modules/@remix-run/express/dist/server.js:39:28
at /path/to/remix-express/server.js:37:11
Sentry Logger [log]: [Tracing] Finishing 'remix.server.documentRequest' span on transaction 'routes/error' (a2516edfe3d1ab7c).
Sentry Logger [log]: [Tracing] Discarding transaction because its trace was not chosen to be sampled.
GET /error 500 - - 124.865 ms
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Technical Explanation - Remix
HTTP Handler and Adapters. While Remix runs on the server, it is not actually a server. It's just a handler that is given...
Read more >Remix - Sentry Documentation
If you use a custom Express server in your Remix application, you should wrap your createRequestHandler function manually with wrapExpressCreateRequestHandler .
Read more >Super Simple Start to Remix - Kent C. Dodds
Remix App Server started at http://localhost:3000 : This comes from remix-serve which is running a simple express server based on what's in the ......
Read more >Is Remix.run not using node.js as backend? - Stack Overflow
So yes, Remix can run in NodeJS environments as a server, but because of its adapter architecture, it can also provide adapters for...
Read more >Remix + Express - Metronome.sh
Install Remix with the Express adapter · Name your project (e.g. "my-remix-app") · After you name your project, select Just the basics and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the reproduction, @shrzaf!
I was able to solve the issue by setting
tracesSampleRate
(which enables performance tracing) inSentry.init
.The error tracking should work regardless of whether performance tracing is enabled, and it’s already working fine on the base implementation. So I think we should fix that.
Hi @onurtemizkan, here you go: https://github.com/shrzaf/remix-express-sentry
main
contains the broken setup (@sentry/remix version 7.13.0 in this case, but all existing versions >= 7.11.0 would exhibit the same issue). I included a control branch,sentry-7.10
, which demonstrates how the same setup works fine with 7.10.0.