How to gracefully fail an automatic token refresh
Hi all,
I'm using the CallClient from @azure/communication-calling to pick up on and add functionality to incoming Teams calls for users. When creating the teams CallClient, a 'tokenRefresher' can be assigned which periodically calls the method you assign to it. The method has token refresh logic to keep the CallClient working.
With my token refresh method, it is possible that a new token cannot be generated and no token can be returned. This will cause an ugly error in the tokenRefresher itself, and I fear it may crash my application at some point. Because the tokenRefresher is called outside of my managed code, I also can't add any error handling for it.
Is there a way to gracefully fail the tokenRefresher? From what I could tell the documentation recommends to return 'undefined' when no token can be refreshed. However, this still results in a 'Uncaught (in promise) InvalidTokenError: Invalid token specified: must be a string' error which I can't handle.
I understand that there is an abortSingal parameter that I can use, but this only helps with signaling new behavior outside the tokenRefresher, while I want the tokenRefresher itself to abort without error.