Skip to content

Commit

Permalink
[App Check] Install catch handler for promise in Deferred. (#7822)
Browse files Browse the repository at this point in the history
Install catch handlers for promises in the Derferred object used by in AppCheck. There were some cases where the promise was cancelled and this bubbled up error messages to our clients' applications despite this being expected behavior.

This change is to alleviate the logging reported in issue #7805.
  • Loading branch information
DellaBitta authored Nov 29, 2023
1 parent e8ff8b8 commit 1d32137
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-houses-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/app-check': patch
---

Prevent App Check from logging "uncaught" cancelled promises. The cancelled promises are part of App Check's expected behavior, and their cancellation wasn't intended to produce errors or warnings. See issue #7805.
6 changes: 6 additions & 0 deletions packages/app-check/src/proactive-refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class Refresher {
this.stop();
try {
this.pending = new Deferred();
this.pending.promise.catch(_e => {
/* ignore */
});
await sleep(this.getNextRun(hasSucceeded));

// Why do we resolve a promise, then immediate wait for it?
Expand All @@ -74,6 +77,9 @@ export class Refresher {
this.pending.resolve();
await this.pending.promise;
this.pending = new Deferred();
this.pending.promise.catch(_e => {
/* ignore */
});
await this.operation();

this.pending.resolve();
Expand Down

0 comments on commit 1d32137

Please sign in to comment.