Backend logs not sending on Next.JS + Vercel/Prod build (FRESH `create-next-app` + `sentry-wizard` reproduction)
Is there an existing issue for this?
- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [x] I have reviewed the documentation https://docs.sentry.io/
- [x] 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/nextjs
SDK Version
10.11.0
Framework Version
Next v15.5.3
Link to Sentry event
No response
Reproduction Example/SDK Setup
https://github.com/buildpass-au/sentry-test
Steps to Reproduce
-
npx create-next-app@latest sentry-test✔ Would you like to use TypeScript? … Yes ✔ Which linter would you like to use? › ESLint ✔ Would you like to use Tailwind CSS? … Yes ✔ Would you like your code inside asrc/directory? … No ✔ Would you like to use App Router? (recommended) … Yes ✔ Would you like to use Turbopack? (recommended) … Yes ✔ Would you like to customize the import alias (@/*by default)? … Yes ✔ What import alias would you like configured? … @/* -
npx @sentry/wizard@latest -i nextjs --saas --org buildpass --project sentry-test◇ Selected project sentry-test ◇ Installed @sentry/nextjs with NPM. ◇ Do you want to route Sentry requests in the browser through your Next.js server to avoid ad blockers? │ No ● Sounds good! We'll leave the option commented for later, just in case :) ◇ Do you want to enable Tracing to track the performance of your application? │ Yes ◇ Do you want to enable Session Replay to get a video-like reproduction of errors during a user session? │ No ◇ Do you want to enable Logs to send your application logs to Sentry? │ Yes ◆ Created fresh sentry.server.config.ts. ◆ Created fresh sentry.edge.config.ts. ◆ Added new instrumentation.ts file. ◆ Added new instrumentation-client.ts file. ◆ Added Sentry configuration to next.config.ts. (you probably want to clean this up a bit!) ◆ Created app/global-error.tsx. ◇ Do you want to create an example page ("/sentry-example-page") to test your Sentry setup? │ Yes ◆ Created app/sentry-example-page/page.tsx. ◆ Created app/api/sentry-example-api/route.ts. ◆ Created .env.sentry-build-plugin with auth token for you to test source map uploading locally. ◆ Added .env.sentry-build-plugin to .gitignore. -
Use
bun install[0.12ms] ".env" bun install v1.1.30 (7996d06b) [3.66ms] migrated lockfile from package-lock.json
16 packages installed [304.00ms]
- Add consoleLoggingIntegration to all 3 Sentry.init files
integrations: [
Sentry.consoleLoggingIntegration(),
],
-
Change
disableLoggertofalseinnext.config.ts -
Add a console.log to both
sentry-example-apiandsentry-example-page -
Run
bun dev, test both api and frontend routes. Logs will work for both frontend and backend in local dev. I noticed that I wasn't getting any exceptions logged for the api route. I only got the frontend error. -
Run
bun run buildand thenbun run start. -
Test the same routes. No logging ends up in Sentry, including front end logs.
-
Deploy to Vercel. Front end logs work, backend logs do not.
Expected Result
There SHOULD be backend logs when you run a Next.JS server in production mode.
Actual Result
No backend logs at all on both local production build + deployed Vercel build.
Additional Context
Vercel test after hitting https://sentry-test.preview.buildpass.com.au/sentry-example-page and https://sentry-test.preview.buildpass.com.au/api/sentry-example-api
Hey @jonoc330 thanks for writing in! Gonna ask @AbhiPrasad to take a look. My suspicion for now is that this could be related to us not flushing logs correctly on AWS Lambda but admittedly I lack some context on our log buffer and flushing logic.
@Lms24 Thank you!
Hey @jonoc330 thanks for reporting! This seems similar to what was reported in https://github.com/getsentry/sentry-javascript/issues/17689, so going to investigate these two things together.
Any movement on this @AbhiPrasad ?
@jonoc330 if you add the handler from https://github.com/getsentry/sentry-javascript/issues/17689#issuecomment-3307256588 do the flushing issues still happen?
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀