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

Port Forwarding in VS Code is unstable #2642

Open
lalver1 opened this issue Jan 23, 2025 · 1 comment · May be fixed by #2656
Open

Port Forwarding in VS Code is unstable #2642

lalver1 opened this issue Jan 23, 2025 · 1 comment · May be fixed by #2656
Assignees
Labels
bug Something isn't working

Comments

@lalver1
Copy link
Member

lalver1 commented Jan 23, 2025

When debugging the app, port forwarding in VS Code is unstable and in some situations it prevents the user from being able to access the application in their browser.

To Reproduce

Steps to reproduce the behavior:

  1. In VS Code, close all ports, reopen the folder locally, and rebuild the container to start with a fresh dev container, notice the two forwarded ports
    Image
  2. Run the VS Code debugger using the Django: Benefits Client launcher configuration, notice that a third port was added
    Image
  3. In your web browser, navigate to the app running on localhost:DJANGO_LOCAL_PORT where DJANGO_LOCAL_PORT is set in your .env file.
  4. Select a Transit Agency and submit the form Choose this benefit with Agency cardholder selected. Notice that a new port has been added
    Image
  5. The web browser hangs
  6. Stop the debugger
  7. Restart the debugger. Notice that the forwarded addess has changed, the browser is still hangingImage

Expected behavior

The web browser should still be able to reach the application on localhost:DJANGO_LOCAL_PORT

Screenshots

Similar behavior occurs with VS Code running on Linux although the Forwarded Address and Running Process columns look slightly different from VS Code running in macOS.

Image

Desktop

  • OS: macOS Sonoma
  • Browser: Firefox
  • Version: 134.0.1

Additional context

A possible solution is to add "otherPortsAttributes": { "onAutoForward": "ignore" } to devcontainer.json as suggested by https://stackoverflow.com/a/74177846. A description of the otherPortsAttributes property is provided at https://containers.dev/implementors/json_reference/#general-properties and the options that the property can take are shown at https://containers.dev/implementors/json_reference/#port-attributes.
While adding "portsAttributes": { "onAutoForward": "ignore" } could also be a solution, adding this did not make any difference in contrast to adding "otherPortsAttributes": { "onAutoForward": "ignore" }.

@lalver1 lalver1 added the bug Something isn't working label Jan 23, 2025
@machikoyasuda
Copy link
Member

Going to test this possible solution out locally. Thank you for investigating and writing this all out.

@lalver1 lalver1 linked a pull request Jan 31, 2025 that will close this issue
@thekaveman thekaveman moved this from Todo to In review in Digital Services Jan 31, 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
Projects
Status: In review
Development

Successfully merging a pull request may close this issue.

2 participants