redhat-developer / podman-desktop-redhat-account-ext

Podman Desktop Red Hat Account Extension
Apache License 2.0
3 stars 9 forks source link

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

Closed odockal closed 5 months ago

odockal commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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);
      }
    });
};