rsnext/packages
Cowboy Ho 70aad4a2b5
Fix NODE_OPTIONS='--inspect' not running expected (#51467)
## Fixing a bug

Fixes #50489
Fixes #48767
Fixes #45697

## What?
When running `NODE_OPTIONS='--inspect' next dev`
Then go to `http://localhost:3000/`
Will display error message `WebSockets request was expected` like the following screenshot
![image](https://github.com/vercel/next.js/assets/14261588/d2f3e520-7cce-40db-be69-99980804cc51)

Also the debug port for app and page still not follow by user input
When `NODE_OPTIONS='--inspect=8000' next dev` the app debug port still `54151`
![image](https://github.com/vercel/next.js/assets/14261588/e3d25c0e-9d00-4767-94d6-d954776912b2)


## Why?
#50248 added a function `getFreePort()` and it used on debug port and HTTP server port
So conflict happen between debug and HTTP port
Then show up error `WebSockets request was expected`

Here are some references about this error:
https://stackoverflow.com/questions/49766500/websockets-request-was-expected-error-when-using-inspect-brk-option


## How?
1. `getFreePort()` should only use on HTTP server
2. Added `getDebugPort()` for read the port from user input
3. Assign port to each worker
4. Add accurate info log for each debug port, e.g.: `proxy`,`router`,`app`,`page`

When `NODE_OPTIONS='--inspect' next dev` 
![image](https://github.com/vercel/next.js/assets/14261588/2260fdff-13fe-435a-9812-984315c0ea2e)

When `NODE_OPTIONS='--inspect=8000' next dev` 
![image](https://github.com/vercel/next.js/assets/14261588/de6e2f2d-9216-481f-b6db-7c5132e97b6f)

Also fix VSCode debugger
It is worth noting that
We can't hit the breakpoint on the first execution
because the file does not exist there yet or was not compiled
In most cases, the breakpoint can only be triggered normally during the second execution
![image](https://github.com/vercel/next.js/assets/14261588/dccded50-46c5-4b6d-beb7-ff0e5324327a)


Closes NEXT-1179
Closes NEXT-517



Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
2023-06-25 22:31:09 +00:00
..
create-next-app v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
eslint-config-next v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
eslint-plugin-next v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
font v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
next Fix NODE_OPTIONS='--inspect' not running expected (#51467) 2023-06-25 22:31:09 +00:00
next-bundle-analyzer v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
next-codemod v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
next-env v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
next-mdx v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
next-plugin-storybook v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
next-polyfill-module v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
next-polyfill-nomodule v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
next-swc revalidate should be more than a boolean (#51627) 2023-06-24 07:38:39 +00:00
react-dev-overlay v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
react-refresh-utils v13.4.8-canary.2 2023-06-24 02:20:39 +00:00