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
Hot reload and debugger broken on dynamic pages in Next.js 14.2.0-canary.43 with --turbo (broken for all versions of --turbo) - vscode debugger #63740
Comments
Same issue here and assuming it's related to dynamic pages specifically. Everything works fine when omitting |
I can't believe this is not fixed yet. This is literally a development breaking bug for people who use dynamic page routes. And I assume that's a lot of people. I've been diligently following up and trying with each new canary version to no avail for the past few weeks. I am wondering when all turbopack tests are done will it still work or will there be issues outstanding? |
Hey, thank you for trying out Turbopack and sharing your experience! Sorry we haven't been able to get back to your particular issue yet. It landed on the backlog as we weren't able to reproduce the specific issue of hot reloading not working, only that vscode debugger does not work which was not release candidate blocking (bug that could be fixed before the stable release). I've opened a PR on your reproduction to have some code that might reproduce it based on the steps provided: PR. Could you share more details about what you're seeing exactly? From reading the reproduction steps it sounds like you're trying to report 2 separate issues:
However from running the reproduction steps I was only able to confirm one issue:
We tried running the reproduction both on macOS and Windows and HMR/Fast Refresh are being applied correctly. Could you please share additional details so that we can investigate it further? Then we can implement a fix for your particular case. Thanks in advance! |
Just did some investigating with @sokra and found that the reason it doesn't apply is that VS Code's debugger has built-in handling for webpack specific sourcemap mapping, i.e. In the meantime, while we work on landing the change in VS Code, you can use a E.g. I was able to attach the debugger using this config: {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"],
"skipFiles": ["<node_internals>/**"],
"sourceMapPathOverrides": {
"webpack:///./~/*": "${workspaceFolder}/node_modules/*",
"webpack://?:*/*": "${workspaceFolder}/*",
// Temporary Turbopack path
"/turbopack/[project]/*": "${workspaceFolder}/*",
// Eventual Turbopack path
"turbopack://[project]/*": "${workspaceFolder}/*"
}
}
]
} |
As discussed above I've opened a PR on VS Code's JavaScript debugger extension: https://vercel.slack.com/archives/C06BW4K7XPT/p1713960193753119 |
Hi @timneutkens This launch config worked fine for me for the VScode debugger. Although your PR might make it better and easier for others.
The debugger attaches perfectly fine. However, once attaching to one of the breakpoints, and being WITHIN a dynamic route, this error crops up repeatedly.
This only happens on dynamic page routes, not regular page routes. The source of the error is within this code
within next/dist/server/dev/on-demand-entry-handler.js Here's the stack trace
As you can see, it seems to be an issue with the turbopack hot reloader colliding with the debugger itself, and not being able to find the dynamic route. I believe that this issue only occurs when the process is being debugged, however I could be wrong on this and it could be occuring anyway every time the page is hot reloaded. Here is how the dynamic route is set up
and the path is done like this nextjs/app/chat/[id]/page.tsx The error basically makes us unable to use the vscode debugger in development mode with turbopack, specifically with dynamic routes. |
Thanks for the additional details, that clarifies a lot more. It seems you are using Docker but the dockerfile is not provided. Can you share the setup as I still can't be reproduced with the provided steps unfortunately. Could you also clarify if you're actively on a breakpoint when you make changes to the file and then save or if it's something else? |
Thanks for your response @timneutkens . I am not saving the file at all. I am literally moving through the breakpoints as normal with the Vscode debugger. Sometimes the error will appear before even hitting a breakpoint and sometimes after. The error will continuously occur then in a kind of loop until it triggers an issue with the jest worker, which basically nukes the Nextjs server and requires a restart. So basically, one error causes another and then when visiting any page, the app does not work on a development environment
Here's the dockerfile
and the docker-compose.yaml
|
## What? Ensures paths that have spaces in them in `NODE_OPTIONS` are handled. An example of that is VS Code's debugger which adds: ``` --require "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.js" ``` Currently the output is cut off and causes: `invalid value for NODE_OPTIONS (unterminated string)`. Related issue: #63740 <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> Closes NEXT-3226 --------- Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca> Co-authored-by: Ethan Arrowood <ethan@arrowood.dev>
After landing #65046 on canary I was able to verify that it now correctly highlights the underlying error in the setup:
This happens regardless of using Turbopack or webpack. I couldn't find much information about this but the VS Code JS debugger adds @avianion Could you try installing |
Adding
|
I can confirm the crashing issue is fixed. However, unfortuantely, I cannot get my debugger to bind anymore Could not read source map for file:///app/nextjs/.next/server/chunks/ssr/[root%20of%20the%20server]__ef3759..js: ENOENT: no such file or directory, open 'c:\Users\dexim\Desktop\avian\nextjs.next\server\chunks\ssr[root of the server]__ef3759..js.map' My source maps aren't loading, even with the exact config as above. Which is bizzare. |
Here's a screenshot of using the test repo and receiving the error where the source maps are not binding correctly.
That's the error I'm getting. My launch.json is the same as yours. For the record, I'm using Windows 11 - not sure if that makes a difference. |
Thanks for checking! Did some more digging and figured out why it was working for me but not for you, the volume wasn't being mounted: avianion/nextjs-turbo-broken-dynamic-page-hot-reload-and-vscode-debugger#4 With that change it does correctly stop at the breakpoints. Could you verify that and let me know if it works? Thanks! |
@avianion checking in here, is this good to be closed? |
Hi Tim. Give me a few hours to check on this and I will get back to you |
npm ERR! code ERESOLVE optional bonus question (unrelated) how can I use a canary nextjs version with sentry nextjs package? it breaks every time i use a canary package. |
so @timneutkens your fix worked, which is great. However the fix breaks my hot reload. If you noticed in the original code, I was using the docker-compose watch in order to have the hot reload work. It was working fine before. Now I commented it out. So now I have the choice of hot reload working (or manually reloading the entire app) or using the debugger. Hope that makes sense. nextjs: |
@timneutkens @sokra Thanks so much for the help. using a volume mount with docker-compose watch fixed the hot reload issue. So I guess everything is working now. Great job. Closing this. |
Thanks for checking! Glad it's resolved now 🙏 |
Link to the code that reproduces this issue
https://github.com/avianion/nextjs-turbo-broken-dynamic-page-hot-reload-and-vscode-debugger
To Reproduce
To Reproduce:
Current vs. Expected behavior
Current vs. Expected behavior:
Current behavior: Hot reload does not work on dynamic pages, and the debugger breaks, overloading the jest-worker. Next.js searches for the dynamic page in the list of pages but cannot find it.
Expected behavior: Hot reload should work seamlessly on dynamic pages, allowing changes to be reflected immediately without reloading the entire page. The debugger should function correctly without breaking or overloading the jest-worker.
Provide environment information
Which area(s) are affected? (Select all that apply)
Turbopack (--turbo)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
PACK-2881
The text was updated successfully, but these errors were encountered: