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 is already in use" error on CI when jobs ran in parallel #11003
Comments
I'm getting that too recently, on localhost (dev). It happens with node and db integrations, but I wasn't able to track it down to any integration yet. Other projects don't have this problem. It says "vite error" but everything seems to work anyway. |
Would love a PR for this. |
vitejs/vite#16219 could help with this once it lands. |
I'm getting a similar build error here on github codespaces |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I have a CI pipeline on GitLab where jobs can be ran in parallel (e.g a CI runner can be running jobs for multiple merge requests). This causes Vite to throw the following error if multiple
astro
commands are run at the same time, e.g.astro check
orastro sync
.This causes the pipelines to become flaky as Astro is creating Vite dev servers which are all competing for the same default port 24678. Changing the port in the astro config makes no difference.
I did some digging and the culprit seems to be in 2 places where we create a vite server, and set
hmr: false
:From this Vite issue vitejs/vite#13994, it sounds like setting
hmr
to false doesn't disable the WebSocket which is why I'm seeing the "Port is already in use" error.I was able to get around this with patch-package and instead of using
hmr: false
in those places above, I set an object with a random port number, but obviously this isn't ideal. I was able to test this locally by running two commands simultaneouslynpm run astro check & npm run astro check
Is there a better way to deal with this? Apologies if this is more of a Vite issue than an Astro one!
What's the expected result?
I should be able to run multiple jobs in parallel on CI that use
astro
CLI commands.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-g3vfoh?file=package.json
Participation
The text was updated successfully, but these errors were encountered: