Hey guys, does the new Sentry version for Next.js...
# support-questions
Hey guys, does the new Sentry version for Next.js also co-exist with Supertokens already? I believe in version 7.14.0 of Sentry, the SDK will automatically instrument API routes and server-side Next.js data fetching methods with error and performance monitoring.(https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/) After updating to
"@sentry/nextjs": "7.31.1"
"supertokens-node": "^13.0.2"
, I realised that the API routes were giving a 500, with the following message:
Copy code
2023-02-25T17:38:56.455Z    c7afa71e-b4f9-4cad-971c-e1145720392c    ERROR    Uncaught Exception     {"errorType":"Error","errorMessage":"write after end","trace":["Error [ERR_STREAM_WRITE_AFTER_END]: write after end","    at new NodeError (node:internal/errors:387:5)","    at ServerResponse.end (node:_http_outgoing:968:15)","    at ServerResponse.apiRes.end (/var/task/node_modules/next/dist/server/api-utils/node.js:356:25)","    at ServerResponse.res.end (/var/task/node_modules/@sentry/nextjs/cjs/server/wrapApiHandlerWithSentry.js:152:26)","    at processTicksAndRejections (node:internal/process/task_queues:96:5)"]}
Unknown application error occurred
The solution now is to temporarily disable the automatic instrumentation of API route handlers and server-side data fetching functions by setting the
to false.
Copy code
const moduleExports = {
  sentry: {
    autoInstrumentServerFunctions: false,
Now it's still possible to to only wrap specific API route handlers or data fetching functions instead. For API routes, they use the
function. But ideally we would want Sentry to work with Supertokens out of the box. Have you guys looked into this already?
Hey @Rob Schilder
Thanks for pointing this out. We haven’t looked into this, but would love to
It would be most helpful if this is made into a GitHub issue and then we have see it very soon
Yeah I wanted to ask you here before. I could make it into one
That would be most helpful. Thank you
hey! i have made an issue about this here: https://github.com/supertokens/supertokens-node/issues/497 Please feel free to follow it to know when this is solved.