Skip to content

[Question]: Possible read/write concurrency issue #2174

@fpra

Description

@fpra

What Version of the library are you using?
19.0.2
...

Question
I'm writing this if form of a question because it could possibly be some misconfiguration on my end and I'm not able to build a reproducible example that works every time.

App:
I have a simple app with a public page (/welcome) and a subset of private pages (/app/....) backed by a Keycloak IDP

  • app.config set with withAppInitializerAuthCheck() and
const config: OpenIdConfiguration = {
  authority: environment.auth.authority,
  clientId: environment.auth.clientId,
  responseType: 'code',
  scope: environment.auth.scope,
  redirectUrl: redirectUri,
  postLogoutRedirectUri: redirectUri,
  secureRoutes: [environment.apiUrl],
  silentRenew: true,
  useRefreshToken: true,
  renewTimeBeforeTokenExpiresInSeconds: 30
};
  • Route 'app' has the autoLoginPartialRoutesGuard applied.
  • Welcome page simply displays a button to redirect to '/app'.

Everything is working fine.
I noticed the issue when I tried to access directly the private page "/app/workspaces/1" when already logged in and with an active Keycloak session, resulting in the app being stuck at the splashscreen with the error "could not find matching config for state XXXXX".
I tried reproducing the error on my local env without any luck.
When opening the page on the deployed env with devtools active , it works every time, without devtools there's a 50% chance the error will appear.

I've replaced withAppInitializerAuthCheck with a custom provideAppInitializer to log some details, I've noticed that at the time of the check my configuration is present without the 'authStateControl' property set.

I managed to write a simple workaround to avoid getting stuck (100ms delay):

provideAppInitializer(() => {
    const oidcSecurityService = inject(OidcSecurityService);
    return timer(100).pipe(switchMap(() => oidcSecurityService.checkAuthMultiple()));
})

Let me know if I can provide any more details.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions