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.

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

See original GitHub issue

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: https://github.com/vercel/next.js/issues/14906 Regression from?: https://github.com/vercel/next.js/issues/8295

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Javicommented, 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.

2reactions
jasonwilliamscommented, Aug 23, 2020

@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
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic routing gives an error when updating the page Next.js
Tell me, there is a problem with dynamic routing. When I click on the link /card/[id] . Then everything works correctly, the id...
Read more >
Devtool - webpack
devtool performance production quality (none) build: fastest rebuild: fastest yes bundle eval build: fast rebuild: fastest no generated eval‑cheap‑source‑map build: ok rebuild: fast no transformed
Read more >
Routing in Next.js – How to Set Up Dynamic Routing with Pre ...
In this tutorial, you'll learn how to set up dynamic routing in Next.js. You'll also learn about pre-rendering and why it's important.
Read more >
Routing - Remix
Nested Routes - The general idea of routes mapping to segments of the URL ... Dynamic Segment - A segment of the route...
Read more >
How to Create Pages in Next.js with Static & Dynamic Data
Why is creating pages important in React? · Creating pages in Next. · Creating dynamic routes in Next. · Data fetching in Next....
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