Skip to content

[@sentry/nextjs] Webpack plugin uploads too much stuff #3769

Closed
@lobsterkatie

Description

@lobsterkatie

This is an offshoot of vercel/next.js#26588, specifically this comment, regarding @sentry/nextjs 6.8.0.

TL;DR - We need to clean up our use of SentryWebpackPlugin such that

  • it doesn’t upload stuff it shouldn't, and
  • it doesn't upload the same stuff twice.

More specifically:

  • We shouldn't be uploading .css.map files.
  • We shouldn't be uploading the same file twice.
  • We (possibly? probably?) shouldn't be uploading HMR files.
  • We (possibly? probably?) shouldn't be uploading webpack files.
  • We may want to consider whether or not to upload nextjs, react, and other vendor files.

All of this can be fixed by changing our default webpack plugin ignore option, either for all builds (for the .css.map files, for example) or conditionally (to not upload client files during the server build, for example, which should prevent the duplication), but the question is what exactly it should be changed to.

Notes:

  • CSS map files

    I filed [sourcemaps] Exclude CSS maps if excluding CSS files sentry-cli#990 for a more long-term fix, but in the meantime we can just exclude them with the ignore option.

  • Duplicated files

    I think the easiest way to handle this is to have server and client builds each only upload their own files, as mentioned above. We'll need to experiment to make sure that we no files get missed this way.

  • HMR files (xyz.hot-update.js files in .next/static/webpack/)

    By default, the webpack plugin is in dryRun mode in dev (which is what produces HMR files), so this ought to be a moot point but a) people do all kinds of crazy things, and b) even when they don't, anyone using nextjs 10.x who runs yarn dev followed by yarn build will end up with HMR files because yarn build doesn't clear out .next before running (this is fixed in nextjs 11).

    I'm not sure exactly how hot-reloading works. Is there ever any circumstance in which we'd want to upload those files?

  • Webpack files (.next/server/webpack-runtime.js and .next/static/chunks/webpack-[hash].js)

    Again, not a webpack expert, but given that the SDK currently only works at runtime, is there any reason we'd need these?

  • Nextjs, React, and other vendor files (everything in .next/static/chunks that's not a page, and whichever .next/server/chunks/[num].js file has nextjs code rather than user code in it)

    Though there's some utility in being able to deminify third-party code, it may or may not be worth the time it takes to upload it. Perhaps this should be configurable? Also, is there any way to predict which of the .next/server/chunks/[num].js files is the one which contains nextjs code rather than user code? In my test app it's always 846.js, but I doubt that's always the case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions