Repository navigation
Description
Is 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 SDK are you using?
@sentry/remix
SDK Version
7.101.1
Framework Version
2.6.0
Link to Sentry event
No response
SDK Setup
No response
Steps to Reproduce
Follow the Remix Vite migration guide with a custom Express app server. Specifically, use the Vite dev server in middleware mode and pass a function to createRequestHandler.
createRequestHandler({
build: viteDevServer
? () =>
viteDevServer.ssrLoadModule(
"virtual:remix/server-build"
)
: await import("./build/server/index.js"),
})Expected Result
Sentry instruments the server build whether it is passed as a function or a static build. If the server build is a function, Sentry wraps the function and instruments the result when it is called.
Actual Result
Sentry's monkey patch fails with an error.
TypeError: Cannot read properties of undefined (reading 'module')
at instrumentBuild (node_modules/.pnpm/@sentry+remix@7.101.1_@remix-run+node@2.6.0_@remix-run+react@2.6.0_react@18.2.0/node_modules/@sentry/src/utils/instrumentServer.ts:519:36)
at Object.<anonymous> (node_modules/.pnpm/@sentry+remix@7.101.1_@remix-run+node@2.6.0_@remix-run+react@2.6.0_react@18.2.0/node_modules/@sentry/src/utils/instrumentServer.ts:565:36)
at createRequestHandler (node_modules/.pnpm/@remix-run+express@2.6.0_express@4.18.2_typescript@5.3.3/node_modules/@remix-run/express/dist/server.js:36:28)
This was previously marked as resolved (#9500) by a workaround that was added to the docs where instead of passing the build as a function, you instead have to call the function and await the result. But as mentioned in this comment, that is not a good idea because it breaks HDR (the whole point of passing the function is that it is re-evaluated on every request, so that in dev you always get the latest server build after making changes, without having to reload the app server).
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
lforst commentedon Feb 22, 2024
Hi, sorry for the late reply, we are taking a look at this!
feat(remix): Add Vite dev-mode support to Express instrumentation. (#…
AbhiPrasad commentedon Feb 26, 2024
we merged this fix in, but now have to backport this onto the v7 branch - so re-opening issue until release is cut there.
feat(remix): Add Vite dev-mode support to Express instrumentation. (#…
feat(remix): Add Vite dev-mode support to Express instrumentation. (#…
feat(remix): Add Vite dev-mode support to Express instrumentation. (#…
feat(remix): Add Vite dev-mode support to Express instrumentation. (#…
AbhiPrasad commentedon Mar 8, 2024
Fixed released with https://github.com/getsentry/sentry-javascript/releases/tag/7.106.0