New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Remix]: Sentry server instrumentation breaks loadContext parameter to handleRequest #8265
Closed
3 tasks done
Labels
Comments
This is impacting me as well and is blocking me from adding Sentry to EpicStack. Here's the branch where you can recreate the bug: https://github.com/scefali/epic-stack/tree/scefali/sentry |
dawnmist
added a commit
to dawnmist/sentry-javascript
that referenced
this issue
Jun 1, 2023
2 tasks
dawnmist
added a commit
to dawnmist/sentry-javascript
that referenced
this issue
Jun 1, 2023
Hi @dawnmist thanks for reporting! We'll take a look at this soon (cc @onurtemizkan). |
closed via #8268 |
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.53.1
Framework Version
Remix 1.16.1
Link to Sentry event
https://support-budget.sentry.io/issues/4217820559/?project=4505236358037504&referrer=project-issue-stream
SDK Setup
Server-side (these break the application):
(Also reproduced with the Prisma integration on the server, but the issue occurs regardless of any integrations provided).
Client-side (though testing has shown that the site runs ok with only the client-side integration present, so client options are only included for completeness - they do not affect the bug):
I have created a sample repository with a reproduction of the problem, starting from Kent C Dodd's Epic Web Stack.
Repository: https://github.com/dawnmist/sentry-remix-load-context-undefined.git
Branches:
main
: freshly created remix stack usingnpx create-remix@latest --typescript --install --template epicweb-dev/epic-stack
sentry-remix-load-context-undefined
: added sentry instrumentation as per the document at: https://docs.sentry.io/platforms/javascript/guides/remix/Note: the linked Sentry error is from my actual application when I was trying to trace what was going wrong, as I had tried to implement the nonce handling from the Epic Stack into my existing application then found that it completely broke. It took several hours and completely replacing my entry.server.ts file with a fresh one from that stack, then slowly adding changes back one at a time, to track the issue down to being due to the Sentry instrumentation. Once I had that, I then did a test using a fresh initialisation of the stack with only the sentry changes added to establish that it really was the addition of the sentry instrumentation that was causing the issue and to create a reproducible example I could provide for this report.
Steps to Reproduce
Working project prior to Sentry instrumentation:
.env.example
file to.env
npm run install
npm run dev
- you should get output like:🔶 Mock server installed ⚠️ Port 3000 is not available, using 3008 instead. 🚀 We have liftoff! Local: http://localhost:3008 On Your Network: http://192.168.1.20:3008 Press Ctrl+C to stop App server took 1.5s
==> you should see the "EPIC STACK" landing page.
To reproduce the Sentry problem:
sentry-remix-load-context-undefined
.env.example
file to.env
, and update the (new to the branch) SENTRY_DSN variable to something you can usenpm run install
to pick up the sentry librariesnpm run dev
- you should get the same output as before==> The page throws the error:
Testing variations locally has shown that if either of the modifications to
./app/entry.server.ts
(Sentry.init on the remix server) or./server/index.ts
(using wrapExpressCreateRequestHandler) are present the remix server will not receive the value created for theloadContext
parameter to thehandleRequest
function in./app/entry.server.ts
file. The client side Sentry.init does not affect the issue at all.Expected Result
The function
handleRequest
in./app/entry.server.ts
should be properly receiving the context information that is being set in the express server in./server/index.ts
regardless of whether Sentry instrumentation has been applied to the server.Actual Result
If the server has either or both of the
Sentry.init
on the./app/entry.server.ts
file ORwrapExpressCreateRequestHandler
used in an express server that runs the remix server, the context being set with thegetLoadContext
option to thecreateRequestHandler
function is not passed through to the remix application in thehandleRequest
function'sloadContext
parameter.The text was updated successfully, but these errors were encountered: