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

start-server-and-test failure wait for localhost of react-app Node.js 18 #356

Closed
MikeMcC399 opened this issue Feb 24, 2023 · 6 comments · Fixed by #357
Closed

start-server-and-test failure wait for localhost of react-app Node.js 18 #356

MikeMcC399 opened this issue Feb 24, 2023 · 6 comments · Fixed by #357
Labels

Comments

@MikeMcC399
Copy link

MikeMcC399 commented Feb 24, 2023

This is a follow-on from the issue #348 "Next.js server start hangs".

Environment

$ npm ls
react-app-test@0.1.0
├── @testing-library/jest-dom@5.16.5
├── @testing-library/react@13.4.0
├── @testing-library/user-event@13.5.0
├── cypress@12.6.0
├── react-dom@18.2.0
├── react-scripts@5.0.1
├── react@18.2.0
├── start-server-and-test@1.15.4
└── web-vitals@2.1.4

Node.js 18.14.x
Windows 11 local
ubuntu-22.04 on GitHub

Problem description

start-server-and-test fails waiting for http://localhost:3000 locally on Windows 11 with Node.js 18.14.2 and on GitHub in an ubuntu-22.04 runner using the current default Node.js 18.14.1.

Debug logs show

making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: connect ECONNREFUSED ::1:3000

So the IPv6 address ( ::1) is being tested whilst the server is only listening on the IPv4 address (127.0.0.1).

Steps to reproduce

Windows 11 local

Clone https://github.com/MikeMcC399/react-app-test

nvm use 18.14.2
npm ci
export DEBUG=start-server-and-test
npm run test:cypress

test hangs although the default browser successfully opens http://127.0.0.1:3000.

$ netstat -an | grep LISTENING | grep 3000
  TCP    0.0.0.0:3000           0.0.0.0:0              LISTENING

curl receives a reponse for:
http://localhost:3000
http://127.0.0.1:3000
not for
http://[::1]:3000

GitHub

View workflow log https://github.com/MikeMcC399/react-app-test/actions/workflows/test-react-app.yml or
fork https://github.com/MikeMcC399/react-app-test and run
.github/workflows/test-react-app.yml

Workaround

wait for http://127.0.0.1:3000 instead of http://localhost:3000

On Windows 11

npm run test:cypress:workaround

Related issues

@MikeMcC399
Copy link
Author

I don't know if start-server-and-wait should be changed since it seems that the problem is in the webservers which do not bind to both IPv4 and IPv6 stacks.

Perhaps the resolution should be to add documentation to the README to workaround such servers by specifying one of the following?

  • 127.0.0.1 or
  • [::1] or
  • ip6-localhost (used on GitHub runners)

instead of localhost

@MikeMcC399
Copy link
Author

When start-server-and-test is outputting the error message in debug mode:

making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: connect ECONNREFUSED ::1:3000

the default webbrowser (in my case Google Chrome) is successfully displaying http://localhost:3000

image

I made a note about this in the original posting.

@MikeMcC399
Copy link
Author

MikeMcC399 commented Feb 26, 2023

@github-actions
Copy link

🎉 This issue has been resolved in version 1.15.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@MikeMcC399
Copy link
Author

🎉 This issue has been resolved in version 1.15.5 🎉

Unfortunately this is not the case. The issue is still reproducible with 1.15.5.

You can now view react-app-test in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.202.1:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

webpack compiled successfully
Error: Timed out waiting for: http://localhost:3000

@MikeMcC399
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant