Skip to content

Keyclock init sometimes does not resolve promise #262

Open

Description

@oleksiirugik

Describe the bug

Hi guys,

I have electron app and in my application something like this:

  return this.keycloak.init({
     onLoad: 'check-sso' as KeycloakOnLoad,
     ...initOptions,
   });

and this promise will be never resolver or rejected, it's happening not so often, but anyway, is it possible to check this issue?

Version

26.2.3

Expected behavior

keyclock.init should resolved or rejected.

Actual behavior

keyclock.init sometimes stuck without any response.

How to Reproduce?

When use keyclock.logout.

Anything else?

No response

Activity

  1. added
    kind/bug
    on Feb 6, 2026
  2. added theissue type on Feb 6, 2026
  3. jonkoops commented on Feb 6, 2026

    @jonkoops
    Contributor

    We'll need a bit more information to go on to be able to identify this bug. Can you provide a minimal and reproducible example that includes the minimal set of options that makes the problem reproducible? Please note that Electron is not an officially supported platform, so it might have quirks that cause this problem to manifest.

    Please provide any additional details such as logs (console, and network) to see if something is going wrong in the background.

  4. oleksiirugik commented on Feb 6, 2026

    @oleksiirugik
    Author

    @jonkoops

    just we do logout => login => logout => login and etc and sometimes it stacks.

    I found a place in authSuccess where we have dead promise.

    if (error) {
          if (prompt !== 'none') {
            if (oauth.error_description && oauth.error_description === 'authentication_expired') {
              await this.login(oauth.loginOptions)
            } else {
              const errorData = { error, error_description: oauth.error_description }
              this.onAuthError?.(errorData)
              throw errorData
            }
          }
          return
        } 
    
    

    If I change to code below it would never stuck again.

    if (error) {
          if (prompt === 'none') {
            // Silent check failed, not an error - just means user is not authenticated
            this.#logInfo('[KEYCLOAK] Silent authentication check failed: ' + error)
            return
          }
          if (oauth.error_description && oauth.error_description === 'authentication_expired') {
            await this.login(oauth.loginOptions)
            return
          }
          const errorData = { error, error_description: oauth.error_description }
          this.onAuthError?.(errorData)
          throw errorData
        } 
    
  5. jonkoops commented on Feb 12, 2026

    @jonkoops
    Contributor

    I am definitely a fan of an early return pattern for code readability, but the examples here both have the same exit points, so I don't see how this change should help. Perhaps your product has some instrumentation to allow capturing stack traces? That could give a hint of what is going wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    Fields

    No fields configured for bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions