sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Backend logs not sending on Next.JS + Vercel/Prod build (FRESH `create-next-app` + `sentry-wizard` reproduction)

Open jonoc330 opened this issue 4 months ago • 6 comments

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

  1. 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 a src/ 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? … @/*

  2. 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.

  3. 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]

  1. Add consoleLoggingIntegration to all 3 Sentry.init files
integrations: [
    Sentry.consoleLoggingIntegration(),
],
  1. Change disableLogger to false in next.config.ts

  2. Add a console.log to both sentry-example-api and sentry-example-page

  3. 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.

  4. Run bun run build and then bun run start.

  5. Test the same routes. No logging ends up in Sentry, including front end logs.

  6. 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

Image Image

jonoc330 avatar Sep 12 '25 02:09 jonoc330

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 avatar Sep 15 '25 08:09 Lms24

@Lms24 Thank you!

jonoc330 avatar Sep 16 '25 00:09 jonoc330

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.

AbhiPrasad avatar Sep 18 '25 19:09 AbhiPrasad

Any movement on this @AbhiPrasad ?

jonoc330 avatar Nov 03 '25 02:11 jonoc330

@jonoc330 if you add the handler from https://github.com/getsentry/sentry-javascript/issues/17689#issuecomment-3307256588 do the flushing issues still happen?

AbhiPrasad avatar Nov 03 '25 15:11 AbhiPrasad

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 🥀

getsantry[bot] avatar Dec 16 '25 08:12 getsantry[bot]