-
Notifications
You must be signed in to change notification settings - Fork 351
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
example-wait-on fails on GitHub waiting for localhost #802
Comments
The migration of the default version of Node.js to 18 in GitHub runners has unmasked an issue with those webservers used for testing which only listen on either IPv4 or IPv6 network stacks but not on both. Node.js 17 changed the order that IP addresses are returned by DNS. If web servers are not listening on IPv4 and IPv6 ports in parallel, then depending on the network setup for There is a known issue with react-scripts (see facebook/create-react-app#11302) that the server does not bind to IPv6. The vite server only binds to one stack and this depends on the version of Node.js and the result of the nameserver resolution (see vitejs/vite#10638 (comment)). Due to GitHub assigning Other webservers used in the examples listen on both IP stacks so do not exhibit any problem in this regard due to the Node.js migration. The non-impacted servers are: Resolution
both these references are unambiguous. ReferenceNode.js 17.0.0 in nodejs/node@1b2749ecbe "(SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup() (treysis)". See Node.js dns.lookup(hostname[, options], callback): History "v17.0.0 The verbatim options defaults to true now." "verbatim When true, the callback receives IPv4 and IPv6 addresses in the order the DNS resolver returned them. When false, IPv4 addresses are placed before IPv6 addresses. Default: true (addresses are not reordered). Default value is configurable using dns.setDefaultResultOrder() or --dns-result-order." |
|
Had the same issue with a vite server using node 16 Fixed with:
Seems the vite server was returning 404 from HEAD requests, worked fine when sending either an |
Many thanks for your tip using I changed the example to I also tried it for the react-scripts example (using port 3000 instead) where it didn't work. It seems there is not a "one-size-fits-all" solution here. Your |
I found that using Would be good to know why your |
Thanks again for your tips! Enabling
This confirms the original finding that |
Hi @flotwig ! What do you think about involving GitHub at this point? They seem to have a non-standard Some Cypress tests are failing because the Cypress GitHub action wait-on function is going over the wrong stack IPv4 or IPv6 and thinks the server is not running because it's not listening on the stack that wait-on is pinging on. This impacts both the wait-on using the built-in ping and wait-on using the external wait-on package. Is it too early to involve GitHub here (for instance through https://github.com/actions/runner-images/issues)? |
If the vite server is started with npx vite --host instead of
then it responds locally to On GitHub it works around the issue described here. This is described in the Vite Server Options server.host documentation. |
Resolved in #803 - thank you for diagnosing this issue, @MikeMcC399 |
Thank you for merging! This is the best workaround we have available at this time. We will need "Happy Eyeballs" implementing to deal with the Node.js >= 17 network dns resolution changes which are currently affecting a lot of repositories since the default Node.js update to 18 by GitHub on Feb 18, 2023. I will follow up on this as I try to understand more about what is going on! |
Should this fix also CRA scripts or just Vite? |
This was aimed to workaround problems in the examples only. I can't guarantee that the same workarounds will work everywhere else, on every operating system, and with all the different incarnations that CRA can produce, although you may find that replacing If you are using the built-in If you are using the npm package wait-on, for example In some cases it may be possible simply to remove the |
Thank you for the answer and the clarification, yeah I'm using the npm package, |
Problem ------- Cypress tests sporadically fail. Solution -------- Trying the approach from cypress-io/github-action#802
Problem ------- Cypress tests sporadically fail. Solution -------- Trying the approach from cypress-io/github-action#802 Signed-off-by: Justin R. Wilson <[email protected]>
IMPORTANT
The example-wait-on workflow fails on GitHub in some jobs waiting for
localhost
after the ubuntu-22.04 runner was migrated to use Node.js 18 as default. GitHub reports that the migration deployed on Feb 18, 2023 on the same date that example-wait-on began failing some of its test jobs. Other test jobs waiting forlocalhost
succeed however.Problem description
The workflow .github/workflows/example-wait-on.yml fails in jobs:
wait-using-custom-command-v9
/wait-using-custom-command
wait-on-vite-v9
/wait-on-vite
The last successful run was on Feb 17, 2023 with ubuntu-22.04 image Version: 20230206.1 using the default Node.js 16.19.0.
The first failed run was on Feb 18, 2023 ubuntu-22.04 image Version: 20230217.1 using the default Node.js 18.14.1.
See https://github.com/cypress-io/github-action/actions/workflows/example-wait-on.yml for workflow history.
wait-using-custom-command
shows
with wait-on --verbose enabled it shows that wait-on is trying to connect to the IPv6 address
::1
, however the react server is only listening on the IPv4 address127.0.0.1
:wait-on-vite
shows
Investigation
GitHub ubuntu-22.04 image Version: 20230217.1 is set up as follows:
/etc/hosts
loopback
Discussion
It is unclear why the wait-on step is causing problems using
localhost
on GitHub where Cypress manages to successfully test usinglocalhost
after the wait-on step whenlocalhost
has been substituted by a non-ambiguous alternative (see Workaround section below). Running Cypress tests locally succeeds. So the problem is only on GitHub.A default installation of Ubuntu only assigns
localhost
to the ip4 address127.0.0.1
, not to the ip6 address::1
. GitHub however has::1 localhost ip6-localhost ip6-loopback
set up in addition.Similar issues on GitHub have already been reported in:
The example-wait-on workflow uses different combinations of servers and wait-on providers to monitor the availability of a server on the network address
localhost
. Some succeed others fail.Workarounds
Use specific localhost
wait-using-custom-command
replacelocalhost
by127.0.0.1
and wait for http://127.0.0.1:3000wait-on-vite
replacelocalhost
byip6-localhost
and wait for http://ip6-localhost:5173Tie tests to Node.js 16
Alternatively: If the failing tests are reverted to running under Node.js 16, then they succeed. Add the following:
Suggestion
Replace the generic term
localhost
by a specific reference:127.0.0.1
ip6-localhost
for these webserver which are not listening on both IP stacks.
The text was updated successfully, but these errors were encountered: