Skip to content

@sentry/nextjs 7.15 and 7.16 have issues with @vercel/nft #5998

Description

@kachkaev

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.15.0 / 7.16.0

Framework Version

Next 12.3.1

Link to Sentry event

No response

Steps to Reproduce

When upgrading blockprotocol/blockprotocol from @sentry/nextjs@7.13.0 to 7.15.0 or 7.16.0, my app started responding with 500 on Vercel. It was working fine locally, which did not make sense at first. I managed to link this problem to @vercel/nft (part of Next.js) and created an MWE here:
https://github.com/hasharchives/sentry-vercel-nft-issue/branches/all

The bug it is to do with Sentry corrupting *.nft.json build files.

The default no-sentry branch in my MWE contains a simple Next.js app that consists of a page with getServerSideProps and an API route. Both files read data.json in the repo root. When the app is built, Next creates .next/server/pages/**/*.nft.json files which are then used on Vercel to determine which files to include in which lambdas. These files are normally .gitignore-ed but I’ve added them to the MWE repo:

Autogenerated *.nft.json files are one-liners. I ran yarn dlx prettier --write .next/server/pages/**/*.nft.json and then ordered file paths alphabetically to ease comparison.

As you can see, both files above refer data.json which is correct.

Installing @sentry/nextjs@7.13.0 or @sentry/nextjs@7.14.0 results in more items in *.nft.json but does not affect the presence of data.json – that’s good:

However, switching to newer versions of @sentry/nextjs causes data.json to disappear:

Although the result of next build works locally via yarn start, the Vercel deployment ends up corrupt because of the missing references. Lambda logs show this:


ERROR	Error: /var/task/data.json: ENOENT: no such file or directory, open '/var/task/data.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Object.readFileSync (/var/task/node_modules/jsonfile/index.js:50:22)
    at Object.9791 (/var/task/.next/server/chunks/9791.js:70:49)
    at __webpack_require__ (/var/task/.next/server/webpack-runtime.js:25:42)
    at /var/task/.next/server/chunks/845.js:1566:78
    at Function.__webpack_require__.a (/var/task/.next/server/webpack-runtime.js:89:13)
    at Object.8841 (/var/task/.next/server/chunks/845.js:1548:21)
    at __webpack_require__ (/var/task/.next/server/webpack-runtime.js:25:42)
    at /var/task/.next/server/chunks/845.js:1508:89 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/var/task/data.json'
}
2022-10-19T23:27:47.506Z	173a20e7-ba14-4fa6-b23b-231c674bbf84	ERROR	null
RequestId: 173a20e7-ba14-4fa6-b23b-231c674bbf84 Error: Runtime exited with error: exit status 1
Runtime.ExitError

Expected Result

data.json is included in *.nft.json files for all tested @sentry/nextjs versions.

Actual Result

data.json is included in *.nft.json files for @sentry/nextjs@7.13.0 and @sentry/nextjs@7.14.2, but not for @sentry/nextjs@7.15.0 and @sentry/nextjs@7.16.0. When the app is deployed to Vercel without data.json in *.nft.json, lambdas crash because the cannot open the file.

Links

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions