cypress-io / github-action

GitHub Action for running Cypress end-to-end & component tests
https://on.cypress.io/guides/continuous-integration/github-actions
MIT License
1.36k stars 358 forks source link

wait-on failing because of MaxRedirectsError #1212

Closed Floriferous closed 2 months ago

Floriferous commented 3 months ago

Hello there,

I'm trying to use this github action to run cypress e2e tests on my software. However I'm getting stuck in a redirect loop and don't know how to debug it. There are a bunch of undefined's in the error message as well, so I'm not sure what to do. I can't reproduce it locally either.

Does someone have an idea for how I could address this?

Here's the end of the github action run (currently with DEBUG: '@cypress/github-action':

/usr/local/bin/npm run start-prod
> software@0.1.0 start-prod
> next start
  ▲ Next.js 14.2.4
  - Local:        http://localhost:3000
 ✓ Starting...
 ⚠ "next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js" instead.
 ✓ Ready in 324ms
2024-07-04T10:20:36.034Z @cypress/github-action got error {"name":"MaxRedirectsError","code":"ERR_TOO_MANY_REDIRECTS"}
2024-07-04T10:20:36.034Z @cypress/github-action 2238ms undefined undefined ERR_TOO_MANY_REDIRECTS attempt 2
2024-07-04T10:21:06.513Z @cypress/github-action got error {"name":"MaxRedirectsError","code":"ERR_TOO_MANY_REDIRECTS"}
2024-07-04T10:21:06.513Z @cypress/github-action 32717ms undefined undefined ERR_TOO_MANY_REDIRECTS attempt 3
2024-07-04T10:21:37.045Z @cypress/github-action got error {"name":"MaxRedirectsError","code":"ERR_TOO_MANY_REDIRECTS"}
2024-07-04T10:21:37.045Z @cypress/github-action 63249ms undefined undefined ERR_TOO_MANY_REDIRECTS attempt 4
2024-07-04T10:22:07.574Z @cypress/github-action got error {"name":"MaxRedirectsError","code":"ERR_TOO_MANY_REDIRECTS"}
2024-07-04T10:22:07.574Z @cypress/github-action 93778ms undefined undefined ERR_TOO_MANY_REDIRECTS attempt 5
http://localhost:3000 timed out on retry 5 of 3, elapsed 93778ms, limit 80000ms
2024-07-04T10:22:07.575Z @cypress/github-action Redirected 10 times. Aborting.
2024-07-04T10:22:07.575Z @cypress/github-action MaxRedirectsError: Redirected 10 times. Aborting.
    at Request._onResponseBase (/home/runner/work/_actions/cypress-io/github-action/v6/dist/index.js:51462:35)
Error: Redirected 10 times. Aborting.
    at Request._onResponse (/home/runner/work/_actions/cypress-io/github-action/v6/dist/index.js:51551:24)
    at ClientRequest.<anonymous> (/home/runner/work/_actions/cypress-io/github-action/v6/dist/index.js:51565:23)
    at Object.onceWrapper (node:events:634:26)
    at ClientRequest.emit (node:events:531:35)
    at origin.emit (/home/runner/work/_actions/cypress-io/github-action/v6/dist/index.js:44636:20)
    at HTTPParser.parserOnIncomingClient (node:_http_client:698:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
    at TLSSocket.socketOnData (node:_http_client:540:22)
    at TLSSocket.emit (node:events:519:28)

This is the cypress part of my yaml file:

      - name: Cypress run
        uses: cypress-io/github-action@v6
        env:
          DEBUG: '@cypress/github-action'
        with:
          build: npm run build-test
          start: npm run start-prod
          wait-on: 'http://localhost:3000'
          wait-on-timeout: 50
Floriferous commented 3 months ago

I ran the exact same setup but replaced:

wait-on: 'http://localhost:3000'

with

wait-on: 'npx wait-on --timeout 60000 http://localhost:3000'

And now it works, very strange.

MikeMcC399 commented 2 months ago

@Floriferous

Can we close this issue now, since you write that you found a workaround?

Floriferous commented 2 months ago

Well to me there still seems to be an open issue, even though it has a workaround. I've seen repos use a label called "has-workaround" without closing. So I guess it's ultimately a philosophical decision the maintainers have to take :)

MikeMcC399 commented 2 months ago

@Floriferous

I suspect that the webserver wasn't ready when it was identified as being ready by wait-on: 'http://localhost:3000'. There is some information in the README Debugging waiting for URL to respond about debugging this situation.

I can't say why wait-on: 'npx wait-on --timeout 60000 http://localhost:3000' worked whereas wait-on: 'http://localhost:3000' did not work.

I noticed your logs have a warning, which may or may not be significant:

⚠ "next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js" instead.

I'm not sure where the undefined in the debug log comes from. The action is reporting an error from calls to Node.js network services invoked through the npm module got

        debug(
          `${elapsed}ms ${error.method} ${error.host} ${error.code} attempt ${attemptCount}`
        )

If you want to provide a public repro showing the issue, we can dig in deeper. The benefit would be to understand why there is a failure, but I don't expect this is a bug in the action.

The question about closing or not closing is more a practical one. If the issue is left open it means there is more work to be done and that only makes sense if some further investigation is going to take place and either a documentation change or a fix to the action is expected. If nothing more is going to be done, then closing the issue says the work is finished.

Floriferous commented 2 months ago

You're right, it works for me so I probably won't investigate further either!

Practical decision, let's close this :) Thank you for the thorough response!