Skip to content

@sentry/nextjs not working when deployed to Vercel #3441

@pudgereyem

Description

@pudgereyem

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:@sentry/nextjs

Version:

6.3.0

Description

I'm trying to integrate @sentry/nextjs, to my Next.js application. However, when deploying to Vercel the application falls over due to an error in the code. See stacktrace below.

ERROR	Unhandled error during request: Error: EROFS: read-only file system, open './node_modules/@sentry/next-plugin-sentry/package.json'
    at Object.openSync (fs.js:462:3)
    at Object.writeFileSync (fs.js:1384:35)
    at syncPluginVersionWithNextVersion (/var/task/node_modules/@sentry/nextjs/dist/utils/config.js:34:8)
    at Object.<anonymous> (/var/task/node_modules/@sentry/nextjs/dist/utils/config.js:80:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18) {
  errno: -30,
  syscall: 'open',
  code: 'EROFS',
  path: './node_modules/@sentry/next-plugin-sentry/package.json'
}

It seems like the function syncPluginVersionWithNextVersion() from @sentry/nextjs is trying to update ./node_modules/@sentry/next-plugin-sentry/package.json, which Vercel doesn't allow.

@iker-barriocanal, I can see that you commented that this is necessary:

Next requires that plugins be tagged with the same version number as the currently-running next.js package, so
modify our package.json to trick it into thinking we comply. Run before the plugin is loaded at server startup.

I tried to look up this and it does indeed seems to be the case, see PR; vercel/next.js#19084.

However, It seems unnecessary to do this during runtime on every request in a serverless environment. I'm thinking that there has to be a better solution to this issue. I've posted the question to the developers of Next.js here, hopefully they have good input.

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