Problem with Ionic InAppBrowser

I’m using Ionic 5 + Angular to develop a proprietary mobile application. For signing in I’m using a local SSO server and appauth (package ionic-appauth from NPM).

Sometimes, when the app needs to fetch a token from the server, if a request fails then the app gets stuck in the InAppBrowser and does not get redirected back, displaying only a white screen. If I inspect the app through the developer tools then I see it says that “Chrome” is open and the page title is “untitled”.

Is there anyway to go around this issue?