quarto-dev / quarto-dev/quarto
Too many ports get forwarded
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 645
- Forks
- 62
- Avg merge
- 17h 42m
- Merged PRs (30d)
- 13
Description
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
- Write a document in VS Code in
.mdformat. - Press Ctrl/Cmd+K to run Quarto. (It works, the preview opens, great.)
- Make some edits to your document, save. (Most of the time, it does not recompile, in my experience.)
- Press Ctrl/Cmd+K to run Quarto. (It works, the preview updates, great.)
- Repeat the above steps as you work, many times.
- 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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the Quarto CLI invocation and Quarto VS Code extension integration described in the report, beginning with how repeated runs allocate and expose ports to VS Code. Define one supported lifecycle or port-reuse behavior, then reproduce the repeated Ctrl/Cmd+K workflow in a VS Code dev container or WSL and verify obsolete forwarded ports are not left behind.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- cli, developer-experience
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100