Skip to content
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

[Bug] eval-source-maps are failing for dynamic routes and don't map properly #15823

Closed
jasonwilliams opened this issue Aug 3, 2020 · 15 comments
Labels
Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Milestone

Comments

@jasonwilliams
Copy link

Bug report

Sourcemaps are not being generated properly from next.js

Describe the bug

Sourcemaps don't generate the correct sources path because it truncates dynamic paths (e.g [id])

To Reproduce

  1. Clone next.js and go to https://github.com/vercel/next.js/tree/master/examples/dynamic-routing (master branch or 9.5)
  2. install dependencies, then run yarn|npm run dev
  3. go to localhost and click "first post"
  4. Now go into the .next folder, server -> pages -> post -> [id].js
  5. Search for /***/ "./pages/post/[id]/index.js":
  6. Select the base64 content and run pbpaste | base64 -D on the command line
  7. inspect the JSON output.
{"version":3,"sources":["webpack:///./pages/post//index.js?a773"]}

notice id has been truncated in the url.
This has broken debugging.

Now, still in the same folder (dynamic routing), change the next.js version in the package.json to 9.3.6

  1. yarn install
  2. yarn dev
  3. same as before navigate to the first post
  4. inspect static/development/pages/post/[id].js.map
{"version":3,"file":"static/development/pages/post/[id].js","sources":["webpack:///webpack/bootstrap","webpack:///external \"next/dist/next-server/lib/router-context.js\""]}

You can see file is set correctly.

It looks like there was a change between v9.3.6 and v9.4.0 which switches to eval source maps and that doesn't support dynamic routes.
The only change i can see however is an upgrade of the source-maps package.

Expected behaviour

Sourcemaps should have the proper dynamic routes on them so debugging can work

Related to: #14906
Regression from?: #8295

@timneutkens
Copy link
Member

Seems like a bug in the way that webpack handles those source paths (replaces [id] and probably [name] as well) 👍

@Timer Timer added the Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). label Aug 3, 2020
@Javi
Copy link

Javi commented Aug 5, 2020

Want to chime in to add breakpoints work correctly on dynamic routes on v9.4.0, and start breaking on v9.4.1 and on. I've tried the latest version, and also Webpack 5 beta. So it does seem to be a regression of #8295

@jasonwilliams
Copy link
Author

jasonwilliams commented Aug 12, 2020

Seems like a bug in the way that webpack handles those source paths (replaces [id] and probably [name] as well) 👍

@timneutkens Ok interesting.
Is something you've raised upstream?

@timneutkens
Copy link
Member

Is something you've raised upstream?

I haven't it's still something that can be investigated by contributors here.

@jasonwilliams
Copy link
Author

@timneutkens would it be worth not forcing people to use eval until this is fixed? I understand it’s a little more optimised in some situations but I think that advantage is overshadowed by it not handling routes.

It essentially blocks anyone from debugging while that’s in place and will be a forced-downgrade for many.

Warning: Reverting webpack devtool to 'eval-source-map'.
Changing the webpack devtool in development mode will cause severe performance regressions.
Read more: https://err.sh/next.js/improper-devtool

@timneutkens
Copy link
Member

@timneutkens would it be worth not forcing people to use eval until this is fixed? I understand it’s a little more optimised in some situations but I think that advantage is overshadowed by it not handling routes.

It essentially blocks anyone from debugging while that’s in place and will be a forced-downgrade for many.

Warning: Reverting webpack devtool to 'eval-source-map'.
Changing the webpack devtool in development mode will cause severe performance regressions.
Read more: https://err.sh/next.js/improper-devtool

It would take the equivalent amount of work to investigate this issue or make the change you're suggesting so I'd suggest investigating and fixing it.

@Javi
Copy link

Javi commented Aug 26, 2020

I may be a bit of a drag but being able to debug is critical to our process, so I can't upgrade to 9.5 until this is fixed or has a workaround, yet the docs don't support old versions and I'm starting to run into signs in them saying to upgrade, which is getting frustrating. Has this been raised upstream? I want to try my hand at it.

@jasonwilliams
Copy link
Author

@Javi i raised it here webpack/webpack#11456 feel free to chase it up

@jasonwilliams
Copy link
Author

Hey @timneutkens
I've attempted to reproduce this issue using just webpack and taking next out of the equation. It doesn't happen with webpack directly so I'm not sure if this is an upstream issue.

See here: webpack/webpack#11456 (comment)

@timneutkens
Copy link
Member

Given that Next.js configures webpack to create the sourcemaps and we don't have any custom plugins that change sourcemaps it's unlikely that it's an issue directly related to Next.js. Either way this still has to be looked into.

@tunesmith
Copy link
Contributor

It sounds like a webpack@5 fix is in progress, hopefully will be made to webpack@4 too. Are there any other workarounds other than putting debugger: everywhere?

@Timer
Copy link
Member

Timer commented Jan 4, 2021

Fixed by webpack/webpack#11927

@Timer Timer closed this as completed Jan 4, 2021
@Timer Timer modified the milestones: 10.x.x, iteration 15 Jan 4, 2021
@matt-koevort
Copy link

matt-koevort commented Mar 9, 2021

Suggestions on how to use the fix in webpack@5?

Have followed the NextJS instructions to use webpack 5, and can confirm it is being used in next.config - but filenames are still encoded.

@jasonwilliams
Copy link
Author

@matt-koevort instructions from here? #21679 (comment) or from the website?

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Projects
None yet
Development

No branches or pull requests

7 participants