Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
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/[email protected]
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/[email protected]
or @sentry/[email protected]
results in more items in *.nft.json
but does not affect the presence of data.json
– that’s good:
sentry-7.13
.next/server/pages/index.js.nft.jsonsentry-7.13
.next/server/pages/api/hello.js.nft.jsonsentry-7.14
.next/server/pages/index.js.nft.jsonsentry-7.14
.next/server/pages/api/hello.js.nft.json
However, switching to newer versions of @sentry/nextjs
causes data.json
to disappear:
sentry-7.15
.next/server/pages/index.js.nft.jsonsentry-7.15
.next/server/pages/api/hello.js.nft.jsonsentry-7.16
.next/server/pages/index.js.nft.jsonsentry-7.16
.next/server/pages/api/hello.js.nft.json
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/[email protected]
and @sentry/[email protected]
, but not for @sentry/[email protected]
and @sentry/[email protected]
. When the app is deployed to Vercel without data.json
in *.nft.json
, lambdas crash because the cannot open the file.
Links
- 7.15 release notes
- Possible regression source: feat(nextjs): Enable
autoInstrumentServerFunctions
per default #5919