jeffbski / wait-on

wait-on is a cross-platform command line utility and Node.js API which will wait for files, ports, sockets, and http(s) resources to become available
MIT License
1.87k stars 77 forks source link

Can't make wait-on work in Github action #86

Open alexbjorlig opened 3 years ago

alexbjorlig commented 3 years ago

Hi Jeff.

Thanks for an awesome library, but I can't get it to work on Github actions.

I use this command:

npm run start:test & ./node_modules/.bin/wait-on http://localhost:3000 --timeout 120000 -v

I can tell from the output that the server is up and running on port 3000, but wait-on only prints this output:

2021-01-03 11:42:52 info: Express is 👂  on port 3000/graphql. (Pid 2995)
making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: Request failed with status code 500
making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: Request failed with status code 500
making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: Request failed with status code 500
making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: Request failed with status code 500
making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: Request failed with status code 500
making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: Request failed with status code 500
making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: Request failed with status code 500
making HTTP(S) head request to  url:http://localhost:3000 ...
  HTTP(S) error for http://localhost:3000 Error: Request failed with status code 500
making HTTP(S) head request to  url:http://localhost:3000 ...

When I test it locally it works perfect?

matart15 commented 3 years ago

same here. http://localhost:4100/graphql http://localhost:4100/ both throw error. tried http-get and that failed too

but I can access it from browser. Also tcp succeeds

$ wait-on -t 300 -v http://localhost:4100/graphql
waiting for 1 resources: http://localhost:4100/graphql
making HTTP(S) head request to  url:http://localhost:4100/graphql ...
  HTTP(S) error for http://localhost:4100/graphql Error: Request failed with status code 500
making HTTP(S) head request to  url:http://localhost:4100/graphql ...
  HTTP(S) error for http://localhost:4100/graphql Error: Request failed with status code 500
wait-on(82273) Timed out waiting for: http://localhost:4100/graphql; exiting with error
$ wait-on -t 300 -v tcp:4100
waiting for 1 resources: tcp:4100
making TCP connection to 4100 ...
  TCP connection successful to host:localhost port:4100
wait-on(82530) complete
✨  Done in 0.67s.
done
jeffbski commented 3 years ago

That's very strange, I'll see if I can figure anything out with this. I appreciate you mentioning it.

On Wed, May 26, 2021 at 9:51 PM matart15 @.***> wrote:

same here. http://localhost:4100/graphql http://localhost:4100/ both throw error. but I can access it from browser. Also tcp succeeds

$ wait-on -t 300 -v http://localhost:4100/graphql

waiting for 1 resources: http://localhost:4100/graphql

making HTTP(S) head request to url:http://localhost:4100/graphql ...

HTTP(S) error for http://localhost:4100/graphql Error: Request failed with status code 500

making HTTP(S) head request to url:http://localhost:4100/graphql ...

HTTP(S) error for http://localhost:4100/graphql Error: Request failed with status code 500

wait-on(82273) Timed out waiting for: http://localhost:4100/graphql; exiting with error

$ wait-on -t 300 -v tcp:4100

waiting for 1 resources: tcp:4100

making TCP connection to 4100 ...

TCP connection successful to host:localhost port:4100

wait-on(82530) complete

✨ Done in 0.67s.

done

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jeffbski/wait-on/issues/86#issuecomment-849277517, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABMOPM6PCM4XLUSNITWM3TPWXUHANCNFSM4VRZ2VKQ .

-- Jeff Barczewski Founder of CodeWinds http://codewinds.com/ Live and Online developer training

filipedeschamps commented 3 years ago

Has anyone found any solution for this? I'm having the exact same problem and something strange is happening: it seems to work with 4.0.0 release, but not with 6.0.0.

alumni commented 2 years ago

If you're using cypress, this sounds interesting: https://github.com/bahmutov/start-server-and-test/issues/287#issuecomment-955592294

byhow commented 2 years ago

also having the same issue here, unable to wait-on the start in github actions. Maybe an issue with the github ci?

mifi commented 1 year ago

For me this was related to ipv6. It also happens with other HTTP request node libraries. Node.js seems to resolve localhost:3000 to ::1:3001, but my server was running on ipv4 only. Solved by using 127.0.0.1:3000 instead of localhost:3000

JoseGaldamez commented 1 year ago

In my case, I wanted to run electron with a React App, then the script on package.js was "electron": "wait-on tcp:3000 && electron ." change for "electron": "wait-on http://127.0.0.1:3000 && electron ." fix the issue.

joriswitteman commented 1 year ago

Some people are having better luck in GitHub Actions with the IP 172.17.0.1

janbrasna commented 5 months ago

There is also related info in: https://github.com/cypress-io/github-action/issues/802

For anyone having issues with Node 18 runners on GitHub Actions, try with Node 20 that has different defaults. At the same time GHA's IPv6 hosts/localhost configuration used to be quite specific, so you may end up having to use ip6-localhost to wait-on unambiguously even for ipv6-binding server.