Skip to content

React Router Framework on Netlify #16186

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

Open
3 tasks done
cjoecker opened this issue May 2, 2025 · 5 comments
Open
3 tasks done

React Router Framework on Netlify #16186

cjoecker opened this issue May 2, 2025 · 5 comments

Comments

@cjoecker
Copy link

cjoecker commented May 2, 2025

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react-router

SDK Version

9.15.0

Framework Version

No response

Link to Sentry event

7.5.0

Reproduction Example/SDK Setup

No response

Steps to Reproduce

  1. Add Sentry to React Router as described in the documentation on the netlify app example
  2. Deploy to Netlify
  3. Throw a server error

Expected Result

  1. Error is shown on Sentry

Actual Result

  1. Error is not shown in Sentry

I guess the instrument.server.mjs cannot be started on Netlify functions

@chargome
Copy link
Member

chargome commented May 5, 2025

Hey @cjoecker, thanks for reporting!

Will have a look at this.

ref #15198

@cjoecker
Copy link
Author

cjoecker commented May 5, 2025

@chargome thanks for checking it!

As a workaround, I added this to the netlify.toml

[functions]
  included_files = ["instrument.server.mjs"]

And also needed to add this environment variable to Netlify: NODE_OPTIONS="--import ./instrument.server.mjs"

If you find a way to add Sentry to the server without the instrument.server.mjs, it will be great since I can imagine that will create issues with other hosting providers.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 5, 2025
@chargome
Copy link
Member

chargome commented May 5, 2025

@cjoecker thanks for the hint!

If you find a way to add Sentry to the server without the instrument.server.mjs, it will be great since I can imagine that will create issues with other hosting providers.

Yes this is generally a pain point with ESM frameworks, if for example you just import the instrumentation file first you will get incomplete instrumentation – which is why we need to rely on the --import flag for now (check out https://github.com/getsentry/esm-observability-guide if you're insterested in details!).

@getsantry getsantry bot removed the status in GitHub Issues with 👀 3 May 5, 2025
@mydea mydea added the Improvement label May 7, 2025 — with Linear
@mydea mydea removed the Bug label May 7, 2025
@mydea mydea added the Feature label May 7, 2025 — with Linear
@mydea mydea removed the Improvement label May 7, 2025
@cjoecker
Copy link
Author

cjoecker commented May 8, 2025

@chargome, the workaround I thought would work on Netlify, is not working after it is deployed on production.

I opened this support ticket on Netlify, but with the current Sentry setup for React Router, it cannot be deployed there.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 8, 2025
@chargome
Copy link
Member

chargome commented May 8, 2025

@cjoecker you can still import the instrument file on the top of your entry.server.ts file – but as mentioned you will have incomplete instrumentation this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants