Skip to content

wait-on example changes for react-scripts and vite server under Node.js 18#803

Merged
flotwig merged 3 commits into
cypress-io:masterfrom
MikeMcC399:fix/wait-on-localhost
Feb 27, 2023
Merged

wait-on example changes for react-scripts and vite server under Node.js 18#803
flotwig merged 3 commits into
cypress-io:masterfrom
MikeMcC399:fix/wait-on-localhost

Conversation

@MikeMcC399

@MikeMcC399 MikeMcC399 commented Feb 19, 2023

Copy link
Copy Markdown
Collaborator

This PR resolves issue #802 "example-wait-on fails on GitHub waiting for localhost".

Due to the migration of GitHub runners to use Node.js 18, name resolution is behaving differently when accessing localhost. This affects webservers used for testing which only listen on IPv4 or IPv6, but not on both network stacks.

In example-wait-on it changes the network name / address

  • to wait for react-scripts server using the IPv4 address 127.0.0.1

and

to allow the respective servers to be monitored until they are running, at which time control is passed to Cypress to carry out testing.

Replace localhost by 127.0.0.1 or ip6-localhost for webservers in examples which do not listen on both IPv4 and IPv6 stacks
@MikeMcC399 MikeMcC399 marked this pull request as ready for review February 19, 2023 14:42
@MikeMcC399

Copy link
Copy Markdown
Collaborator Author

Until this PR is merged all other PRs will fail tests due to wait-on failures.

@MikeMcC399 MikeMcC399 marked this pull request as draft February 20, 2023 14:00
@MikeMcC399

Copy link
Copy Markdown
Collaborator Author

In draft, pending investigation of new vite version v4.1.3.

@MikeMcC399

MikeMcC399 commented Feb 20, 2023

Copy link
Copy Markdown
Collaborator Author

The wait-on-vite issue is not resolved by updating to VITE 4.1.3 (latest)

image

so I suggest to go ahead with this PR.

The log confirms again the issue with GitHub dual definition of localhost.

waiting on "http://localhost:5173" with timeout of 60 seconds
/usr/local/bin/npm run dev

> example-wait-on-vite@2.0.0 dev
> vite


  VITE v4.1.3  ready in 201 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
http://localhost:[51](https://github.com/MikeMcC399/github-action/actions/runs/4224214377/jobs/7334897450#step:3:52)73 timed out on retry 91 of 3, elapsed 90279ms, limit 90000ms
Error: connect ECONNREFUSED 127.0.0.1:5173
  1. vite declares it is listening on http://localhost:5173/ Local: http://localhost:5173/
  2. GHA says waiting on "http://localhost:5173" with timeout of 60 seconds
  3. The error message Error: connect ECONNREFUSED 127.0.0.1:5173 shows that the name resolution leads to pinging on the wrong stack (IPv4 127.0.0.1) instead of IPv6 ::1.

See vite developer's information about stack and name usage depending on Node.js versions vitejs/vite#10638 (comment) which does not tie in to what is observed on GitHub currently.

@MikeMcC399 MikeMcC399 marked this pull request as ready for review February 20, 2023 14:19
@MikeMcC399 MikeMcC399 marked this pull request as draft February 25, 2023 09:00
@MikeMcC399 MikeMcC399 marked this pull request as ready for review February 25, 2023 11:55
@MikeMcC399

Copy link
Copy Markdown
Collaborator Author

I resolved the vite issue by changing the startup of vite server to npx vite --host which causes it to listen on all addresses (0.0.0.0).

I had found this workaround some time ago, but I only just located the documentation in Vite Server Options server.host which confirms that it is a supported option.

@flotwig flotwig self-requested a review February 27, 2023 15:33
@flotwig flotwig merged commit 63a7518 into cypress-io:master Feb 27, 2023
@MikeMcC399 MikeMcC399 deleted the fix/wait-on-localhost branch February 27, 2023 16:06
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants