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

can't open URL after stopping the debugger attached to Chrome #1795

Closed
rhwinter opened this issue Sep 7, 2023 · 0 comments · Fixed by #1934
Closed

can't open URL after stopping the debugger attached to Chrome #1795

rhwinter opened this issue Sep 7, 2023 · 0 comments · Fixed by #1934
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@rhwinter
Copy link

rhwinter commented Sep 7, 2023

Describe the bug
Stopping the debugger attached to a ReactJS application open in Chrome doesn't seem to release a port, Chrome then is unable to load the URL that was being debugged. Using Chrome 116.0.5845.179 and 'JavaScript Debugger (Nightly)'. Trying on a ReactJS project running from Terminal on port 3000. All on macOS Big Sur.

To Reproduce
Steps to reproduce the behavior:

  1. Create a debug config adding to workspace.code-workspace:
"launch": {
    "version": "0.2.0",
    "configurations": [
        {
            "name": "client",
            "type": "chrome",
            "request": "attach",
            "urlFilter": "http://localhost:3000/*",
            "webRoot": "${workspaceFolder}",
      	    "port": 9222,
        },		  
    ]
}
  1. Launch Chrome with --remote-debugging-port=9222:
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
  1. Run a ReactJS app from Terminal using yarn, on port 3000:
$ yarn start
  1. Go back to Chrome and navigate to http://localhost:3000/
  2. Go to VSCode and run the created debugger. So far, it all works as expected.
  3. Stop the debugger in VSCode (doesn't matter if I click the 'disconnect' icon or click the drop down and select Stop)
  4. Go back to Chrome, the tab on https://localhost:3000/ will still be there and working (if I click Stop in the previous step, the tab is gone). But if I try to open a new tab and navigate to that same URL it doesn't load (it hangs on loading forever). The only way to make the URL open again is by restarting VSCode.

VS Code Version: 1.82.0 (Universal)

Additional context
A possible hack/workaround is to create a postDebugTask attribute (added after "port": 9222,, in the debug configuration shown above):

"postDebugTask": "killdebugger"

And then create that global task which kills the VSCode process running on a port, adding the following to tasks.json:

"tasks": [
        {
            "label": "killdebugger",
            "type": "shell",
            "command": "kill `lsof -i|grep localhost|grep Code|awk '{print $2}'`"
        }
]

This works partially (I haven't tested thoroughly): after stopping the debug and waiting for the process to be killed, Chrome can navigate once again to the localhost URL, but VSCode seems to work erratically (occasionally, other extensions don't function properly?).

This seems to be very similar to this bug: #1731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants