-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[nextjs] Original source code visible in browser dev tools #4489
Comments
Hi, @kelvinndmo. What you want is a combo of Cheers! |
I created a webpack plugin to achieve this with nextjs, it will build the sourcemaps, upload them to sentry and then remove them so they won't be there at the end of the build and won't be uploaded to your production server |
Thanks for sharing! BTW, your readme says
but that's no longer true: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map. |
Let's revisit this conversation and figure out if there's something we can do to improve DX.
|
We talked about this as a team, and we're going to deal with this in stages. There are a few different considerations here:
Our first stage will be to assume we're last, check the incoming config, and if we're the ones to set Our second stage will be to consider deleting sourcemaps after we upload them, again assuming that we're the last to change the webpack config. Our third stage, if we decide to delete source maps, will be to actually parse We are going into a weeklong code freeze starting Monday (and will not make any releases before then), but will begin work on this today and pick it back up after after we return. |
Update: A slightly modified version of the first stage mentioned above has now been PR-ed.
Further update: All of the above are merged and released. I'm going to move this to the backlog for potential future work on stages 2 and 3 mentioned above. Hopefully this stage 1 implementation solves the immediate problem, though. Last update (I swear!): In order to prepare for a possible future in which we delete source maps, I've filed a feature request in the |
…5464) This expands the explanation of the `hideSourceMaps` option in `next.config.js`, and notes that it will default to `true` starting in version 8 of the SDK. In conjunction with getsentry/sentry-javascript#5649, getsentry/sentry-wizard#188, and vercel/next.js#40079, this is the first step in addressing the concerns raised in getsentry/sentry-javascript#4489. See getsentry/sentry-javascript#4489 (comment) for more details.
This adds a default value for `hideSourceMaps` to the `next.config.js` the wizard provides, so that new users will use `hidden-source-map` as their Webpack `devtool` by default in client-side builds. (This prevents browser devtools from seeing sourcemaps and therefore prevents original source code from showing up automatically in the `Sources` tab. (More information on `devtool` values can be found at https://webpack.js.org/configuration/devtool/.) In conjunction with getsentry/sentry-javascript#5649, getsentry/sentry-docs#5464, and vercel/next.js#40079, this is the first step in addressing the concerns raised in getsentry/sentry-javascript#4489. See getsentry/sentry-javascript#4489 (comment) for more details.
This adds a warning during nextjs app build (both in prod and dev) letting folks know that by default (for now), the sourcemaps we create can be seen by browser devtools. In conjunction with getsentry/sentry-wizard#188, getsentry/sentry-docs#5464, and vercel/next.js#40079, this is the first step in addressing the concerns raised in #4489. See #4489 (comment) for more details. Notes: - The function doing the warning includes both the current warning and one for use in v8 and beyond (currently commented out), telling people they no longer need to set `hideSourceMaps` to `true` (because by that point it will be the default). - The formatting of the warning matches the formatting of other nextjs warnings. Because nextjs vendors `chalk` themselves, that meant we needed to add it as a dependency. Though the latest version of `chalk` is 5.x, here we're using 3.x because it's the last to be compatible with node 8. (See the PR for a screenshot.) - There are `TODO`s reflecting the changes which need to be made in v8 (change the default to `true`, switch the warning message) and v9 or v10 (get rid of the second warning once it's had plenty of time to do its job).
This adds a default value for `hideSourceMaps` to the `next.config.js` the `with-sentry` example app provides, so that new users will use `hidden-source-map` as their Webpack `devtool` by default in client-side builds. (This prevents browser devtools from seeing sourcemaps and therefore prevents original source code from showing up automatically in the `Sources` tab. (More information on `devtool` values can be found [here](https://webpack.js.org/configuration/devtool/).) In conjunction with getsentry/sentry-javascript#5649, getsentry/sentry-wizard#188, and getsentry/sentry-docs#5464, this is the first step in addressing the concerns raised in getsentry/sentry-javascript#4489. See [here](getsentry/sentry-javascript#4489 (comment)) for more details.
We can think about blocking requests for source maps with Next.js rewrites automatically. |
Hello, is this considered a problem? I mean is the source code still visible when the app is deployed (on vercel...)? |
@OtmaniCodes if you set the |
Package + Version
@sentry/browser
@sentry/node
raven-js
raven-node
(raven for node)Version:
Description
Describe your issue in detail, ideally, you have a reproducible demo that you can show.
I have used sentry/nextjs to upload the source maps to sentry, however, i can be able to see my source code on production, attached here is a screenshot, if i remove sentry from the next config file, the folder doesn't exist anymore, i have tried all options but haven't succeeded, any help will be appreciated.
The text was updated successfully, but these errors were encountered: