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/@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/@sentry/src/utils/instrumentServer.ts:519:36)
at Object.<anonymous> (node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/@sentry/src/utils/instrumentServer.ts:565:36)
at createRequestHandler (node_modules/.pnpm/@[email protected][email protected][email protected]/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
Type
Projects
Status