@sentry/browser
@sentry/node
raven-js
raven-node
_(raven for node)_>=5.24.0
Hello, we use Sentry for our Serverless applications which use NestJS and the nest-raven library that implements an interceptor to catch the errors and report them to Sentry.io and everything is bundled using Webpack. After we upgraded from 5.23.0
to the last version 5.26.0
we noticed that when an exception happens we receive an Internal Server Error and the original Exception is not reported to Sentry.io because it is the Sentry library that is having problems. The backend logs we have are:
聽 | 2020-10-13T14:51:20.131-04:00 | TypeError: mod.require is not a function
-- | -- | --
聽 | 2020-10-13T14:51:20.131-04:00 | at dynamicRequire (/var/task/src/adapters/graphql/handler.js:79802:16)
聽 | 2020-10-13T14:51:20.131-04:00 | at /var/task/src/adapters/graphql/handler.js:79860:39
聽 | 2020-10-13T14:51:20.131-04:00 | at Array.forEach (<anonymous>)
聽 | 2020-10-13T14:51:20.131-04:00 | at extractNodeRequestData (/var/task/src/adapters/graphql/handler.js:79845:10)
聽 | 2020-10-13T14:51:20.131-04:00 | at Module.parseRequest (/var/task/src/adapters/graphql/handler.js:131937:61)
聽 | 2020-10-13T14:51:20.131-04:00 | at RavenInterceptor.captureGraphQLException (/var/task/src/adapters/graphql/handler.js:645524:42)
聽 | 2020-10-13T14:51:20.131-04:00 | at Sentry.withScope (/var/task/src/adapters/graphql/handler.js:645514:45)
聽 | 2020-10-13T14:51:20.131-04:00 | at Hub.withScope (/var/task/src/adapters/graphql/handler.js:654823:13)
聽 | 2020-10-13T14:51:20.131-04:00 | at callOnHub (/var/task/src/adapters/graphql/handler.js:13438:28)
聽 | 2020-10-13T14:51:20.131-04:00 | at Module.withScope (/var/task/src/adapters/graphql/handler.js:13572:5)
After analyzing the bundle we noticed that the it happens in the dynamicRequire
function specifically when it's called from packages/utils/src/node.ts line 93 which was introduced in version 5.24.0
.
Checking the stacktrace it happens when Handlers.parseRequests
is called from the Nest-Raven library we use
So far the workaround is to keep using @sentry/[email protected]
where the error does not happen.
@sergio-dreamcode can you provide a simple repro app?
@rbisol Here's the repo https://github.com/kamilchlebek/sentry-express-demo
Run: npm start
and provide environment variable SSR_SENTRY_DSN
. Open localhost:4500/debug-sentry
to trigger an error.
I think it's caused by webpack bundling, have a look at this thread: https://github.com/getsentry/sentry-javascript/pull/2515
Thanks for the sample repo @kamilchlebek. As you mentioned it is possible to be related with webpack by checking #2515. That PR removed the usage of dynamicRequire
however it was introduced again as part of 5.24.0 #2820
@sergio-dreamcode wil #2515 be re-instated? Or was the #2820 reintroduction intentional?
wil #2515 be re-instated? Or was the #2820 reintroduction intentional?
@ybrodsky I'm not sure, I checked in #2515 that removed dynamicRequire
but in #2524 it was restored only for hooks so it was not breaking anything. The change in #2820 seems to be related with hooks but this time is breaking webpack builds as no events can be reported causing the mod.require
error.
Hi, we have encountered the same issue, the only workaround for us was to downgrade to 5.22.0. Any progress on a problem yet?
@rbisol Any updates from Sentry on this?
Hi all, we're running sentry in nodejs angular universal project and we also get this error (in 5.24 and higher versions). I'll be glad to help, if If you need me to try anything.
I tried using import
as in https://github.com/getsentry/sentry-electron/issues/92#issuecomment-453534680 but it doesn't work
import { init } from '@sentry/node/dist/index';
import * as Sentry from '@sentry/node';
Any other ideas?
To reproduce this, take angular universal zip from https://angular.io/guide/universal and add @sentry/node to it.
A request to /debug-sentry
logs a mod.require is not a function
error and not My first Sentry error
.
@rbisol I think we should remove the Needs Reproduction
tag because @kamilchlebek already provided a repository to reproduce the issue.
@rbisol This has been open and reproducible nearly three months. Downgrading the package version not an appropriate solution. Any updates?
setup "@sentry/node": "6.0.2",
get the same issue
setup "@sentry/node": "6.0.2",
get the same issue
figured out that the problem is in package
"@sentry/tracing": "6.0.2",
when adding app.use(Sentry.Handlers.tracingHandler()) to server code from the docs
Hi, all. This should be fixed once https://github.com/getsentry/sentry-javascript/pull/3210 is released. Please let me know if you're still running into trouble.
"@sentry/node": "6.0.3",
"@sentry/react": "6.0.3",
"@sentry/tracing": "6.0.3",
"webpack": "4.43.0
node 12.14
import * as Tracing from '@sentry/tracing';
import * as Sentry from '@sentry/node';
the same issue
"e.required is not a function" in the prod build and "mod.require is not a function" in dev build
"@sentry/node": "6.0.3",
6.0.4
is coming in few moments. Thanks for your patience.
Most helpful comment
@rbisol This has been open and reproducible nearly three months. Downgrading the package version not an appropriate solution. Any updates?