question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
adamduncancommented, Nov 25, 2022

Appreciate the thorough write-up, @kachkaev 👍 We’re running into the same issue. Trying to readFile from our API routes to generate emails from template files on the server.

Have forked the MWE repo, upgraded @sentry/nextjs to the latest 7.21.1, but the issue still persists.

Our current workaround is to use its new excludeServerRoutes config option to ignore this particular API route that needs filesystem access. E.g.

const moduleExports = {
  sentry: {
    excludeServerRoutes: ['/api/hello']
  }
}
1reaction
lobsterkatiecommented, Nov 3, 2022

Yes, it turns out there are any number of ways for the autowrapping to not play nicely with other packages. Would you please file a separate issue and give the details of the error you’re running into?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploy your Next.js application on Vercel using Sentry and ...
Sentry is an application monitoring platform we're going to integrate into our application. It will provide us with: Automatic Error Tracking ...
Read more >
1.xml - jsDelivr
... monthly https://www.jsdelivr.com/package/npm/3d-model-ts-library-rollup monthly https://www.jsdelivr.com/package/npm/3d-nft-veiwer monthly ...
Read more >
CSSSR - Podcast Addict
Chrome 107, Firefox 106, Next.js 13 и Turbopack, публичное превью Fleet ... TypeScript 4.8, парсинг аргументов в Node.js, планы Bun, фичи CSS :has()...
Read more >
Manual Setup for Next.js - DocBase AI Documentation
import * as Sentry from "@sentry/nextjs"; const SENTRY_DSN = process.env. ... is not called in case of // https://github.com/vercel/next.js/issues/8592.
Read more >
Sentry Expands Code Observability for Next.js - Business Wire
“Sentry has changed how we monitor and respond to errors at Vercel by increasing code visibility and reducing resolution times.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found