cylc-ui icon indicating copy to clipboard operation
cylc-ui copied to clipboard

(WebKit) NoAuth page redirection not happening?

Open MetRonnie opened this issue 1 year ago • 3 comments

On my fork I tested out running the E2E tests on WebKit in GH Actions MacOS, and consistently got this error for tests/e2e/specs/url.cy.js:

  1) URL handling
       reroutes to noAuth page if user isnt authorised:
     Error: The following error originated from your application code, not from Cypress.
            It was caused by an unhandled promise rejection.

  > 

(The error message is empty)

URL handling -- reroutes to noAuth page if user isnt authorised (failed)

MetRonnie avatar Oct 25 '23 15:10 MetRonnie

Screenshot 2024-01-31 at 22 48 19

Found this:

https://stackoverflow.com/questions/62223195/vue-router-uncaught-in-promise-error-redirected-from-login-to-via-a

Sounds like there are multiple redirects going on in the same operation. I get the impression this error might also be ocouring in other browsers, but is only surfacing in the WebKit tests due to this snippet I extracted from the traceback:

  // If the runner can communicate, we should setup all events, otherwise just setup the window and fire the load event.
        if (isRunnerAbleToCommunicateWithAUT) {
          if (this.Cypress.isBrowser('webkit')) {
            // WebKit's unhandledrejection event will sometimes not fire within the AUT
            // due to a documented bug: https://bugs.webkit.org/show_bug.cgi?id=187822
            // To ensure that the event will always fire (and always report these
            // unhandled rejections to the user), we patch the AUT's Error constructor
            // to enqueue a no-op microtask when executed, which ensures that the unhandledrejection
            // event handler will be executed if this Error is uncaught.
            const originalError = autWindow.Error;
            autWindow.Error = function __CyWebKitError(...args) {
              autWindow.queueMicrotask(() => {});
              return originalError.apply(this, args);
            };
          }    

If this is the case, avoiding the double redirect would be the best outcome.

oliver-sanders avatar Jan 31 '24 22:01 oliver-sanders

I can't think how we would be redirecting more than once

https://github.com/cylc/cylc-ui/blob/1cbd0c9781937adf1999d9dee8c94b5ea8834e53/src/router/index.js#L66-L95

MetRonnie avatar Feb 01 '24 10:02 MetRonnie

Worth jamming some logging in to find out if this is the case.

Also worth looking at the error, it says we are redirecting from / to {} which looks like an error too, could possibly be cause the re-re-direct if it's an invalid page?

There was another error in the console (which may be unrelated): "[Network] undefined"

oliver-sanders avatar Feb 01 '24 10:02 oliver-sanders