Skip to content

Commit

Permalink
fix: identity Provider init() should be triggered async (#1415)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbouliere-datasolution authored Apr 18, 2023
1 parent a0e0ebd commit 61c4b0f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/app/core/identity-provider/identity-provider.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ export class IdentityProviderFactory {
console.error('did not find identity provider for config', config);
} else {
const instance = this.injector.get(provider.implementor);
instance.init(config);

/*
If the code is called synchronously, the init method can call other actions that can trigger http requests.
If an HTTP request is triggered before the identity provider constructor is finished, a "Null Pointer Exception" will be thrown in the identity-provider.interceptor.
A delay with setTimeout is added to mitigate this problem
*/
// TODO: Find a way to implement this without setTimeout()
setTimeout(() => {
instance.init(config);
}, 1);

this.instance = instance;
this.config = config;
Expand Down

0 comments on commit 61c4b0f

Please sign in to comment.