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

Random ports appear when exiting debug mode #1092

Closed
khkh-ms opened this issue Aug 30, 2021 · 5 comments
Closed

Random ports appear when exiting debug mode #1092

khkh-ms opened this issue Aug 30, 2021 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug under-discussion Issue is under discussion for relevance, priority, approach

Comments

@khkh-ms
Copy link

khkh-ms commented Aug 30, 2021

Describe the bug
When exiting a JavaScript Debug session from the debug bar, 1 port turns into 3 with two being seemingly random ports.

To Reproduce
Steps to reproduce the behavior:

  1. Open https://github.com/chrisdias/gh-static-e2e with Remote-Container or GitHub Codespaces
  2. Create new JavaScript Debug Terminal
  3. Run npm run server
  4. Disconnect debugger from debug bar

Expected behavior
The debugger is disconnected, but all other UI remains the same.

What happens instead
The debugger is disconnected, but two seemingly random ports are added in the "Ports" view. These go away when the actual terminal process that started the debugger is killed.

VS Code Version: 1.59.1

Additional context
image

@khkh-ms khkh-ms added the bug Issue identified by VS Code Team member as probable bug label Aug 30, 2021
@alexr00
Copy link
Member

alexr00 commented Aug 31, 2021

@connor4312 It looks like this is what's happening:

  1. Javascript debugger terminal is started
  2. Extension returns port attributes that indicate that the processes associated with the debugger terminal should be ignored.
  3. Once the debugger is disconnected from the terminal, the extension stops saying the terminal processes should be ignored.

Would you consider continuing to return Ignore for processes related to JS debug terminals?

@connor4312
Copy link
Member

connor4312 commented Aug 31, 2021

I'm not sure what I want to do here. When you detach from the process but leave it running, js-debug no longer knows about the lifecycle of the process and cannot authoritatively return whether a port is a "debug port".

What triggers the editor to check for port attributes again? VS Code knows the process ID is unchanged, is it expected that port attributes might change for existing (pid, port) pairs?

The simplest solution would be for js-debug to keep a small cache of known pairs itself since we know that debug ports will never become not-debug-ports for any given process, but this is something that I think the editor could also assume.

@connor4312 connor4312 added the under-discussion Issue is under discussion for relevance, priority, approach label Aug 31, 2021
@alexr00
Copy link
Member

alexr00 commented Sep 1, 2021

Hmm, I assumed since JS Debug contributed the terminal profile it would consider all terminals created with that profile to belong to JS Debug in a way, but it sounds like this isn't how terminal profiles work.

VS Code checks for port numbers every couple seconds on a timer and we check for attributes any time there's a change there. We could do the (pid, port) check in VS Code, but attributes can change for based on UI interactions from the user and based on settings changes, though I don't expect those things happen often.

@connor4312
Copy link
Member

it would consider all terminals created with that profile to belong to JS Debug in a way

This is what happens, but given an incoming port/pid we don't know whether that belongs to one of our terminals. We only check to see if we know it because of a debug session, which isn't the case if the user detaches the debugger but leaves the program running.

I'll add a pid/port cache in js-debug to mitigate this.

@alexr00
Copy link
Member

alexr00 commented Sep 2, 2021

Thank you!

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 under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

3 participants