Setup for Remix with custom express server #16758
Unanswered
crestwood204
asked this question in
Q&A
Replies: 1 comment
-
|
hey, can you clarify what did not work with the regular remix setup you had (in entry.server) once you started to use a custom express server? Were express errors/middlewares not captured? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What's the ideal setup for Sentry within a remix app with a custom express server? I am using
"@sentry/remix": "9.24.0"and"@sentry/node": "9.24.0"Original setup
Before I had the custom express server, I had the
@sentry/remixpackage set up in bothentry.clientandentry.serverwhich seemed to work well.New setup
Now that I have the custom express server, I want to have Sentry still catch errors from custom middleware or other things generated within the express server. I added a
instrument.tsfile with aSentry.initfrom@sentry/nodeand changed mystartscript inpackage.jsontonpx tsx --import server/utils/instrument.ts server/index.ts",. I also addedSentry.setupExpressErrorHandler(app);to the end of my server index file.This seems correct except that I found the
Sentry.initin myentry.serveris not working (i.e. if I try to log something in abeforeSendit doesn't fire). I found that theSentry.initin myinstrument.tsfile was the one logging to sentry for my remix server-side errors and that it basically overrode myentry.serverone.So, I deleted my
entry.serverSentry.init.Can't get user attribution to work
But, I'm now having trouble with user attribution (just for the server). Previously, I was using
within my
handleRequestandhandleDataRequestfunction withinentry.server, but I found these no longer worked...I figured that I wanted user attribution on the express server as well anyway, so I got rid of this and created a custom middleware that just callsSentry.setUser. This still doesn't work though.Despite better judgement, I attempted to change the import in my
instrument.tsfile to@sentry/remixand now my user attribution suddenly works! However, I found that in a non-dev instance (i.e.npm run start), returning from a remix action hangs indefinitely! I'm assuming this is because sentry doesn't know it's in express land and doesn't return the response correctly...For now, I've gone back to using
@sentry/nodeon myinstrumentfile, but none of the user attribution is working. Any advice on how to set this up correctly would be appreciated.Beta Was this translation helpful? Give feedback.
All reactions