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

fix(hmr): client pinging behind a proxy on websocket disconnect (fix #4501) #5466

Merged
merged 5 commits into from Mar 3, 2022

Conversation

mwarnerdotme
Copy link
Contributor

Description

When running the Vite dev server behind a proxy, the fetch request results in a 502 status code. This 502 does not throw an error, triggering the catch statement. Instead, the loop breaks (because of the break statement on the next line). When it breaks, the page reloads, but it cannot load because the proxy server is down. This causes those of us working behind proxies to lose frontend application state whenever the proxy restarts.

Additional context

#4501

For my team, this occurs frequently because the proxy is a part of our API code - so whenever we are doing backend work and we need to restart our local API server, our frontend application loses state because the window reloads and can't connect to the proxy.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@mwarnerdotme mwarnerdotme marked this pull request as ready for review October 28, 2021 18:41
@Shinigami92 Shinigami92 added feat: hmr p2-nice-to-have Not breaking anything but nice to have (priority) labels Oct 28, 2021
@BirknerAlex
Copy link

Our team experienced the same issue, we are running our vite development environment on k8s with using devspace. When we are replacing our common JS dependencies for development we are automatically restarting the whole node/vite process since the required optimizeDeps is not working without restarting vite.

During the restart the k8s load balancer returns status code 502 for a few seconds but the browser reloads already the page even if the vite process isn't up and running. A few more retries / waiting time would result in a better development experience inclusive checking the return code.

@Niputi Niputi linked an issue Dec 30, 2021 that may be closed by this pull request
4 tasks
Niputi
Niputi previously approved these changes Dec 30, 2021
Copy link
Contributor

@Niputi Niputi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved from my side.
looks like a alternative to #6090

@Shinigami92
Copy link
Member

In our last meeting we discussed that someone (hopefully from the community) with a matching environment should test this and report if everything worked.
If so, it is okay to get merged.

@Niputi
Copy link
Contributor

Niputi commented Dec 30, 2021

@mwarnerdotme would you run pnpm run format? thanks

@mwarnerdotme
Copy link
Contributor Author

@mwarnerdotme would you run pnpm run format? thanks

done!

@patak-dev
Copy link
Member

patak-dev commented Jan 11, 2022

@wuxiaolin1949 @BirknerAlex could you confirm that this PR works for your setup? We can merge it if this is the case

@fexpanda
Copy link

@wuxiaolin1949 @BirknerAlex could you confirm that this PR works for your setup? We can merge it if this is the case

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: hmr p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
No open projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

优化waitForSuccessfulPing方法
7 participants