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

Red Hat Authentication extension activation/installation failure: outgoing request timed out after 3500 ms #142

Closed
odockal opened this issue May 3, 2024 · 2 comments · Fixed by #144
Assignees
Labels
kind/bug 🐞 Something isn't working
Milestone

Comments

@odockal
Copy link
Contributor

odockal commented May 3, 2024

During installation of the Extension's pack (1.0.1) the sso extension is in the failed state.

sso-ext-failed

Error trace:

Error: outgoing request timed out after 3500ms
Stack trace:
RPError: outgoing request timed out after 3500ms
    at C:\Users\Ondrej\.local\share\containers\podman-desktop\plugins\quayioredhatdeveloperpodmandesktopredhataccountext\dist\extension.js:5608:13
    at async Issuer.discover (C:\Users\Ondrej\.local\share\containers\podman-desktop\plugins\quayioredhatdeveloperpodmandesktopredhataccountext\dist\extension.js:8928:22)
    at async RedHatAuthenticationService.build (C:\Users\Ondrej\.local\share\containers\podman-desktop\plugins\quayioredhatdeveloperpodmandesktopredhataccountext\dist\extension.js:9420:24)
    at async buildAndInitializeAuthService (C:\Users\Ondrej\.local\share\containers\podman-desktop\plugins\quayioredhatdeveloperpodmandesktopredhataccountext\dist\extension.js:30406:21)
    at async Object.getSessions (C:\Users\Ondrej\.local\share\containers\podman-desktop\plugins\quayioredhatdeveloperpodmandesktopredhataccountext\dist\extension.js:30509:29)
    at async cZ.getSession (C:\Users\Ondrej\AppData\Local\Programs\podman-desktop\resources\app.asar\packages\main\dist\index.cjs:71:2908)
    at async activate (C:\Users\Ondrej\.local\share\containers\podman-desktop\plugins\quayioredhatdeveloperpodmandesktopredhataccountext\dist\extension.js:30532:5)
    at async hAe.activateExtension (C:\Users\Ondrej\AppData\Local\Programs\podman-desktop\resources\app.asar\packages\main\dist\index.cjs:146:59277)
    at async hAe.loadExtension (C:\Users\Ondrej\AppData\Local\Programs\podman-desktop\resources\app.asar\packages\main\dist\index.cjs:146:48734)
    at async Promise.all (index 4)

If I click on active button it leads to an error: Error: An authentication provider with id 'redhat.authentication-provider' is already registered.

Which is #135 issue

@odockal odockal added the kind/bug 🐞 Something isn't working label May 3, 2024
@odockal
Copy link
Contributor Author

odockal commented May 3, 2024

It seems that the problem originates in authenticate service method build which is called during activation of the extension here. Though, I am not sure. If the extension is installed/activated individually, problem do not appear.

@odockal
Copy link
Contributor Author

odockal commented May 3, 2024

I have pasted a snippet from the extension.js opened in dev tools. Search for a message: outgoing...

  if (mTLS && !opts.pfx && !(opts.key && opts.cert)) {
    throw new TypeError('mutual-TLS certificate and key not set');
  }

  if (opts.searchParams) {
    for (const [key, value] of Object.entries(opts.searchParams)) {
      url.searchParams.delete(key);
      url.searchParams.set(key, value);
    }
  }

  let responseType;
  let form;
  let json;
  let body;
  ({ form, responseType, json, body, ...opts } = opts);

  for (const [key, value] of Object.entries(opts.headers || {})) {
    if (value === undefined) {
      delete opts.headers[key];
    }
  }

  let response;
  const req = (url.protocol === 'https:' ? https$2.request : http$2.request)(url.href, opts);
  return (async () => {
    if (json) {
      send(req, JSON.stringify(json), 'application/json');
    } else if (form) {
      send(req, querystring$1.stringify(form), 'application/x-www-form-urlencoded');
    } else if (body) {
      send(req, body);
    } else {
      send(req);
    }

    [response] = await Promise.race([once(req, 'response'), once(req, 'timeout')]);

    // timeout reached
    if (!response) {
      req.destroy();
      throw new RPError$7(`outgoing request timed out after ${opts.timeout}ms`);
    }

    const parts = [];

    for await (const part of response) {
      parts.push(part);
    }

    if (parts.length) {
      switch (responseType) {
        case 'json': {
          Object.defineProperty(response, 'body', {
            get() {
              let value = Buffer.concat(parts);
              try {
                value = JSON.parse(value);
              } catch (err) {
                Object.defineProperty(err, 'response', { value: response });
                throw err;
              } finally {
                Object.defineProperty(response, 'body', { value, configurable: true });
              }
              return value;
            },
            configurable: true,
          });
          break;
        }
        case undefined:
        case 'buffer': {
          Object.defineProperty(response, 'body', {
            get() {
              const value = Buffer.concat(parts);
              Object.defineProperty(response, 'body', { value, configurable: true });
              return value;
            },
            configurable: true,
          });
          break;
        }
        default:
          throw new TypeError('unsupported responseType request option');
      }
    }

    return response;
  })()
    .catch((err) => {
      if (response) Object.defineProperty(err, 'response', { value: response });
      throw err;
    })
    .finally(() => {
      const dpopNonce = response && response.headers['dpop-nonce'];
      if (dpopNonce && NQCHAR.test(dpopNonce)) {
        nonces.set(nonceKey, dpopNonce);
      }
    });
};

@dgolovin dgolovin added this to the 1.0.2 milestone May 4, 2024
dgolovin added a commit to dgolovin/podman-desktop-redhat-account-ext that referenced this issue May 4, 2024
Fix redhat-developer#142 by creating authentication request asyncronously and delaying
openid-client ininialization until first authentication request or
token refresh.

Signed-off-by: Denis Golovin <[email protected]>
dgolovin added a commit that referenced this issue May 5, 2024
Fix #142 by creating authentication request asyncronously and delaying
openid-client ininialization until first authentication request or
token refresh.

Signed-off-by: Denis Golovin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants