Skip to content

Too many ports get forwarded #668

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

Open
nathancarter opened this issue Feb 19, 2025 · 0 comments
Open

Too many ports get forwarded #668

nathancarter opened this issue Feb 19, 2025 · 0 comments
Labels
bug Something isn't working vscode

Comments

@nathancarter
Copy link

nathancarter commented Feb 19, 2025

Bug description

As you can see in this discussion thread for the quarto CLI, it creates random ports every time it is run. The problem with this random port process is the workflow listed below, if done in a VS Code dev container, or even just in WSL on Windows. It produces lots of forwarded ports that the VS Code session keeps track of.

Steps to reproduce

  1. Write a document in VS Code in .md format.
  2. Press Ctrl/Cmd+K to run Quarto. (It works, the preview opens, great.)
  3. Make some edits to your document, save. (Most of the time, it does not recompile, in my experience.)
  4. Press Ctrl/Cmd+K to run Quarto. (It works, the preview updates, great.)
  5. Repeat the above steps as you work, many times.
  6. Inspect the VS Code terminal panel to find a large number of forwarded ports, most of which are being used by nothing, because they were all created by quarto CLI runs that have since terminated, but VS Code doesn't know that the port forwarding is no longer needed.

Actual behavior

Lots of forwarded ports, only one of which is actually being used, by the most recent quarto CLI run.

Note that these forwarded ports remain in existence even if VS Code is quit and restarted, because it tries to preserve your last setup. So the only solution I've found is manually closing them one at a time.

Expected behavior

Since it seems like the problem here is that the CLI uses random ports and VS Code is far too accommodating, forwarding as many of them as it needs to (unless you change your settings so that it forwards none of them), the best solution is probably for the Quarto extension for VS Code to get the quarto CLI and VS Code cooperating better. Here are some options for that:

  • Have the quarto VS Code extension tell the CLI to re-use on subsequent runs whatever random port it used on the first run.
  • Have the quarto VS Code extension un-forward the port every time a quarto CLI process stops.
  • Give the quarto VS Code extension a setting to specify the port you want it to use (with a sensible default).

Your environment

  • IDE: VS Code 1.97.2
  • OS: Windows 11 Home
@nathancarter nathancarter added the bug Something isn't working label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vscode
Projects
None yet
Development

No branches or pull requests

2 participants