Skip to content
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

@sentry/nextjs doesn't report server-side errors #6485

Closed
3 tasks done
KELiON opened this issue Dec 9, 2022 · 3 comments
Closed
3 tasks done

@sentry/nextjs doesn't report server-side errors #6485

KELiON opened this issue Dec 9, 2022 · 3 comments
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug

Comments

@KELiON
Copy link

KELiON commented Dec 9, 2022

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.24.2

Framework Version

12.3.0

Link to Sentry event

No response

Steps to Reproduce

We've noticed that at some point Sentry stopped reporting next.js server-side errors on Vercel. I tried example from scratch and only added package-lock.json and debug: true to server-side Sentry config, setup Vercel deployment and I see the same result (example repository)

I open /api/test(1-4) and /ssr/test(1-4) one-by-one and expect to see 8 errors reported, but see only 3.

At the same time if I do npm run build + npm run start locally I see 8 errors reported.

Vercel logs:
[GET] /ssr/test4
19:46:33:94
Sentry Logger [log]: Initializing SDK...
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RewriteFrames
Sentry Logger [log]: SDK successfully initialized
Sentry Logger [log]: [Tracing] starting http.server transaction - /ssr/test4
Sentry Logger [log]: [Tracing] Starting 'function.nextjs' span on transaction '/ssr/test4' (b9bfe82a8dbcd0d5).
Sentry Logger [log]: [Tracing] Finishing 'function.nextjs' span on transaction '/ssr/test4' (b9bfe82a8dbcd0d5).
Sentry Logger [log]: [Tracing] Finishing http.server transaction: /ssr/test4.
Sentry Logger [log]: Flushing events...
Sentry Logger [log]: Done flushing events
[GET] /ssr/test3
19:46:30:58
Sentry Logger [log]: Initializing SDK...
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RewriteFrames
Sentry Logger [log]: SDK successfully initialized
Sentry Logger [log]: [Tracing] starting http.server transaction - /ssr/test3
Sentry Logger [log]: [Tracing] Starting 'function.nextjs' span on transaction '/ssr/test3' (963bef33a5bfecaf).
Sentry Logger [log]: [Tracing] Finishing 'function.nextjs' span on transaction '/ssr/test3' (963bef33a5bfecaf).
2022-12-09T11:46:31.462Z	07f02678-b3aa-478a-82c2-3e29bdde8326	ERROR	Uncaught Exception 	{"errorType":"Error","errorMessage":"SSR Test 3","stack":["Error: SSR Test 3","    at doAsyncWork (/var/task/.next/server/pages/ssr/test3.js:37:44)","    at getServerSideProps (/var/task/.next/server/pages/ssr/test3.js:38:5)","    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:34:33","    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:113:20","    at bound (node:domain:433:15)","    at runBound (node:domain:444:12)","    at Object.callTracedServerSideDataFetcher (/var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:128:5)","    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryGetServerSideProps.js:32:50","    at Object.renderToHTML (/var/task/node_modules/next/dist/server/render.js:506:26)","    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"]}
Unknown application error occurred
Runtime.Unknown
[GET] /ssr/test2
19:46:27:02
Sentry Logger [log]: Initializing SDK...
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RewriteFrames
Sentry Logger [log]: SDK successfully initialized
Sentry Logger [log]: [Tracing] starting http.server transaction - /ssr/test2
Sentry Logger [log]: [Tracing] Starting 'function.nextjs' span on transaction '/ssr/test2' (a37f9c5ac056a4b3).
Sentry Logger [log]: [Tracing] Finishing 'function.nextjs' span on transaction '/ssr/test2' (a37f9c5ac056a4b3).
2022-12-09T11:46:27.934Z	fba5926b-bd34-45aa-b9f6-65e7a7d195e7	ERROR	Error: SSR Test 2
    at getServerSideProps (/var/task/.next/server/pages/ssr/test2.js:37:27)
    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:34:33
    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:113:20
    at bound (node:domain:433:15)
    at runBound (node:domain:444:12)
    at Object.callTracedServerSideDataFetcher (/var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:128:5)
    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryGetServerSideProps.js:32:50
    at Object.renderToHTML (/var/task/node_modules/next/dist/server/render.js:506:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async doRender (/var/task/node_modules/next/dist/server/base-server.js:708:34) {
  page: '/ssr/test2'
}
RequestId: fba5926b-bd34-45aa-b9f6-65e7a7d195e7 Error: Runtime exited with error: exit status 1
Runtime.ExitError
[GET] /ssr/test1
19:46:23:24
Sentry Logger [log]: Initializing SDK...
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RewriteFrames
Sentry Logger [log]: SDK successfully initialized
Sentry Logger [log]: [Tracing] starting http.server transaction - /ssr/test1
Sentry Logger [log]: [Tracing] Starting 'function.nextjs' span on transaction '/ssr/test1' (8b7fc7a9bab92bea).
Sentry Logger [log]: [Tracing] Finishing 'function.nextjs' span on transaction '/ssr/test1' (8b7fc7a9bab92bea).
2022-12-09T11:46:24.616Z	db4eaa71-b488-48ff-a320-a5d9f0080760	ERROR	Error: SSR Test 1
    at getServerSideProps (/var/task/.next/server/pages/ssr/test1.js:37:11)
    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:34:33
    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:113:20
    at bound (node:domain:433:15)
    at runBound (node:domain:444:12)
    at Object.callTracedServerSideDataFetcher (/var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:128:5)
    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryGetServerSideProps.js:32:50
    at Object.renderToHTML (/var/task/node_modules/next/dist/server/render.js:506:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async doRender (/var/task/node_modules/next/dist/server/base-server.js:708:34) {
  page: '/ssr/test1'
}
RequestId: db4eaa71-b488-48ff-a320-a5d9f0080760 Error: Runtime exited with error: exit status 1
Runtime.ExitError
[GET] /api/test4
19:46:14:12
Sentry Logger [log]: Initializing SDK...
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RewriteFrames
Sentry Logger [log]: SDK successfully initialized
Sentry Logger [log]: [Tracing] starting http.server transaction - GET /api/test4
Sentry Logger [log]: [Tracing] Finishing http.server transaction: GET /api/test4.
Sentry Logger [log]: Flushing events...
Sentry Logger [log]: Done flushing events
[GET] /api/test3
19:46:11:11
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RewriteFrames
Sentry Logger [log]: SDK successfully initialized
Sentry Logger [log]: [Tracing] starting http.server transaction - GET /api/test3
Sentry Logger [log]: [Tracing] Finishing http.server transaction: GET /api/test3.
Sentry Logger [log]: Flushing events...
Sentry Logger [log]: Done flushing events
2022-12-09T11:46:12.173Z	d257b257-71b8-4f51-adc2-10046570624e	ERROR	Error: API Test 3
    at work (/var/task/.next/server/pages/api/test3.js:43:11)
    at handler (/var/task/.next/server/pages/api/test3.js:46:5)
    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryAPI.js:132:37
    at bound (node:domain:433:15)
    at runBound (node:domain:444:12)
    at sentryWrappedHandler (/var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryAPI.js:196:12)
    at Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:363:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:474:9)
    at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:736:37)
2022-12-09T11:46:12.173Z	d257b257-71b8-4f51-adc2-10046570624e	ERROR	Error: API Test 3
    at work (/var/task/.next/server/pages/api/test3.js:43:11)
    at handler (/var/task/.next/server/pages/api/test3.js:46:5)
    at /var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryAPI.js:132:37
    at bound (node:domain:433:15)
    at runBound (node:domain:444:12)
    at sentryWrappedHandler (/var/task/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryAPI.js:196:12)
    at Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:363:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:474:9)
    at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:736:37)
RequestId: d257b257-71b8-4f51-adc2-10046570624e Error: Runtime exited with error: exit status 1
Runtime.ExitError
[GET] /api/test2
19:46:07:55
Sentry Logger [log]: Initializing SDK...
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RewriteFrames
Sentry Logger [log]: SDK successfully initialized
2022-12-09T11:46:08.451Z	3054c869-13d7-4e3c-8b3e-a5cce213497e	ERROR	Error: API Test 2
    at work (/var/task/.next/server/pages/api/test2.js:43:11)
    at 6332 (/var/task/.next/server/pages/api/test2.js:45:1)
    at __webpack_require__ (/var/task/.next/server/webpack-api-runtime.js:25:42)
    at __webpack_exec__ (/var/task/.next/server/pages/api/test2.js:99:39)
    at /var/task/.next/server/pages/api/test2.js:100:89
    at __webpack_require__.X (/var/task/.next/server/webpack-api-runtime.js:108:21)
    at /var/task/.next/server/pages/api/test2.js:100:47
    at Object.<anonymous> (/var/task/.next/server/pages/api/test2.js:103:3)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
RequestId: 3054c869-13d7-4e3c-8b3e-a5cce213497e Error: Runtime exited with error: exit status 1
Runtime.ExitError
[GET] /api/test1
19:46:04:28
Sentry Logger [log]: Initializing SDK...
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RewriteFrames
Sentry Logger [log]: SDK successfully initialized
Sentry Logger [log]: [Tracing] starting http.server transaction - GET /api/test1
2022-12-09T11:46:05.634Z	c8fd79fe-5692-4aba-bb98-ffdbc56b5189	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: API Test 1","reason":{"errorType":"Error","errorMessage":"API Test 1","stack":["Error: API Test 1","    at doAsyncWork (/var/task/.next/server/pages/api/test1.js:42:40)","    at 3285 (/var/task/.next/server/pages/api/test1.js:43:1)","    at __webpack_require__ (/var/task/.next/server/webpack-api-runtime.js:25:42)","    at __webpack_exec__ (/var/task/.next/server/pages/api/test1.js:97:39)","    at /var/task/.next/server/pages/api/test1.js:98:89","    at __webpack_require__.X (/var/task/.next/server/webpack-api-runtime.js:108:21)","    at /var/task/.next/server/pages/api/test1.js:98:47","    at Object.<anonymous> (/var/task/.next/server/pages/api/test1.js:101:3)","    at Module._compile (node:internal/modules/cjs/loader:1159:14)","    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: API Test 1","    at process.<anonymous> (file:///var/runtime/index.mjs:1194:17)","    at process.emit (node:events:525:35)","    at process.emit (node:domain:489:12)","    at emit (node:internal/process/promises:149:20)","    at processPromiseRejections (node:internal/process/promises:283:27)","    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}
Unknown application error occurred
Runtime.Unknown

Expected Result

8 errors reported:

/api/test(1-4)
/ssr/test(1-4)

Actual Result

Only 3 events reported:

  • /ssr/test4
  • /api/test3
  • /api/test4
@lforst
Copy link
Member

lforst commented Dec 9, 2022

Hi, thanks for writing in.

SSR tests 1-3 are a duplicate of #6117. Vercel is doing some weird magic that we haven't gotten round to figuring out yet. Have these errors been reported for you in older versions?

API tests 1-2 are anti-patterns for serverless functions. I recommend putting all your logic inside the handlers. It is impossible for the SDK to flush errors happening outside of the handler scope since we can't top-level await at that point to flush and the serverless function/lambda will freeze/quit.

@lforst lforst added Package: nextjs Issues related to the Sentry Nextjs SDK Status: Backlog and removed Status: Untriaged labels Dec 9, 2022
@KELiON
Copy link
Author

KELiON commented Dec 13, 2022

Have these errors been reported for you in older versions?

Looks like we never had server-side events (only test events from local servers)

@lforst
Copy link
Member

lforst commented Dec 13, 2022

Have these errors been reported for you in older versions?

Looks like we never had server-side events (only test events from local servers)

Ok, thanks for checking. I will close this issue as a duplicate of #6117 and #6120 just to keep our backlog clean. Our Vercel compatibility is far from the best at the moment and we're looking to improve this in the very near future. Feel free to ping us if you have any more questions.

@lforst lforst closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants