Skip to content

NextJS/Vercel build fails on pages starting with "/pages/api.../..." (probably related to Server-side Auto-instrumentation) #7122

Closed
@winsvold

Description

@winsvold

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.

@sentry/nextjs

SDK Version

7.36.0

Framework Version

nextjs 13.1.6

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. Clone minimal reproduction repo here: https://github.com/biblioteksentralen/vercel-deploybug-reproduction
  2. vercel build (you need to link it to a new vercel-project, default config, should work out of the box)
  3. Build error

Possible ways to fix build:

  • rename the file /pages/apidoc/[version].tsx to something like /pages/doc/[version].tsx
  • set autoInstrumentServerFunctions: false in next.config.js

Seems like Automatic Instrumentation in Sentry wraps this page as if it was an api-route, probably because it starts with "api".

Expected Result

Builds sucessfully

Actual Result

[    ] info  - Generating static pages (0/4)
Error occurred prerendering page "/apidoc/[version]". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=%5Bobject%20Promise%5D for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions