Skip to content

Commit 5d7a520

Browse files
fix: properly handle forceRefresh errors in App Check token retrieval
1 parent a24a76a commit 5d7a520

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/app-check/src/internal-api.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,19 @@ export async function getToken(
192192
// count this as a failed attempt and use the backoff instead of
193193
// retrying repeatedly with no delay, but any 3P listeners will not
194194
// be hindered in getting the still-valid token.
195-
interopTokenResult = {
196-
token: token.token,
197-
internalError: error
198-
};
195+
if (forceRefresh) {
196+
// If forceRefresh is true, return the error alongside the token
197+
// to propagate the failure properly.
198+
interopTokenResult = {
199+
token: token.token,
200+
error
201+
};
202+
} else {
203+
interopTokenResult = {
204+
token: token.token,
205+
internalError: error
206+
};
207+
}
199208
} else {
200209
// No invalid tokens should make it to this step. Memory and cached tokens
201210
// are checked. Other tokens are from fresh exchanges. But just in case.

0 commit comments

Comments
 (0)