angular-auth-oidc-client icon indicating copy to clipboard operation
angular-auth-oidc-client copied to clipboard

[Bug]: SilentRenewFailed never gets fired

Open benthieu opened this issue 3 years ago • 6 comments

Version

15.0.2

Please provide the exception or error you saw

The event this.publicEventsService.fireEvent(EventTypes.SilentRenewFailed, error); never gets called, because the unsubscribe from the Observable gets called, before the catchError block is reached.

This error was quite tricky to debug, because of the depth of the different pipes. In the RefreshSessionRefreshTokenService in the catchError the intervalService gets called, to stop the periodic tokencheck (if an error occurs -> i.e. the accessToken could not be refreshed). The intervalService then unsubscribes the periodical tokencheck and the catchError block in /periodically-token-check.service.ts never gets called.

A quick fix of the problem would be to move the this.intervalService.stopPeriodicTokenCheck(); to the catchError-block in /periodically-token-check.service.ts to refreshEventWithErrorHandler$. So that the unsubscribe happens there.

Steps to reproduce the behavior

Provoke an error in the silent renew request.

A clear and concise description of what you expected to happen.

EventTypes.SilentRenewFailed to be fired.

benthieu avatar Jan 09 '23 10:01 benthieu

Line that unsubscribes: https://github.com/damienbod/angular-auth-oidc-client/blob/ebd035b0bd0537504a2dff4f4a570d0074437ae6/projects/angular-auth-oidc-client/src/lib/callback/refresh-session-refresh-token.service.ts#L29

Block that never gets called because of the unsubscribe: https://github.com/damienbod/angular-auth-oidc-client/blob/6eb8fd18f6df3fbf3122364acf3c7b2c2bfef8bc/projects/angular-auth-oidc-client/src/lib/callback/periodically-token-check.service.ts#L93

benthieu avatar Jan 09 '23 10:01 benthieu

@FabianGosebrink Is there any news about this issue? Should I clarify the issue better? I could create a fork. Let me know

benthieu avatar Jan 17 '23 08:01 benthieu

Thanks for reaching out. I have to have a look, maybe on the weekend if I find time. If you want to create a fork and a PR, so support this, I'd appreciate it.

FabianGosebrink avatar Jan 17 '23 09:01 FabianGosebrink

https://github.com/damienbod/angular-auth-oidc-client/pull/1655 This could fix the issue

benthieu avatar Jan 18 '23 11:01 benthieu

I have encountered similar results, the EventType of 11 is never fired even though the connect/token is failing on a refresh event

image

export declare enum EventTypes {
    /**
     *  This only works in the AppModule Constructor
     */
    ConfigLoaded = 0,
    CheckingAuth = 1,
    CheckingAuthFinished = 2,
    CheckingAuthFinishedWithError = 3,
    ConfigLoadingFailed = 4,
    CheckSessionReceived = 5,
    UserDataChanged = 6,
    NewAuthenticationResult = 7,
    TokenExpired = 8,
    IdTokenExpired = 9,
    SilentRenewStarted = 10,
    SilentRenewFailed = 11
}

Tyler-V avatar Feb 14 '23 16:02 Tyler-V

@Tyler-V fancy seeing you here. We're having all the same problems.

bluebaroncanada avatar May 02 '23 20:05 bluebaroncanada