Skip to content

wait-on "localhost" not resolving after upgrading Node.js 16 to 18 #634

@casewalker

Description

@casewalker

My project is upgrading from Node 16.14.2 to 18.12.1.

On my local machine using Chrome, going to our homepage (on port 8000) using the "localhost" name works without issue (http://localhost:8000/).

In our Github workflow, we have:

name: CI
on: [push]
env:
  [...]
  NODE_VERSION: 18

jobs:
  [...]
  e2e-test:
    timeout-minutes: 20
    runs-on: ubuntu-latest

    steps:
      - run: echo $HOME
      - name: Check out the code
        uses: actions/checkout@v3

      - name: Use node ${{ env.NODE_VERSION }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'yarn'

      - name: Cypress run
        uses: cypress-io/github-action@v4
        with:
          start: yarn develop
          browser: chrome
          wait-on: "http://localhost:8000/"
          wait-on-timeout: 300
          command-prefix: 'percy exec -- yarn'
      [...]

However, this wait-on ends up timing out, resulting in the error:

...
You can now view [website] in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
...
success Building development bundle - 97.705s
success Writing page-data.json files to public directory - 0.791s - 257/257 324.90/s
http://localhost:8000/ timed out on retry 331 of 11, elapsed 330780ms, limit 330000ms
Error: connect ECONNREFUSED 127.0.0.1:8000

This was working on Node 16 but now breaks on Node 18.

Doing some digging, I came across this discussion in the Node repository, saying that starting with Node 17, the IPv4 address "127.0.0.1" would no longer be accepted by default.

But when I changed my Github config above to use wait-on: "http://[::1]:8000/" instead of localhost, the error went away.
This leads me to believe that wait-on is not being "smart" about localhost.

Please let me know if this is an issue on my side that I should change or if you agree this is something to be tackled on the Cypress side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions