Skip to content

Commit 6998e51

Browse files
authored
fix(app_check,web): fix an error that could occur when refreshing a token (#18135)
1 parent 2525ecb commit 6998e51

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

packages/firebase_app_check/firebase_app_check_web/lib/firebase_app_check_web.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,18 @@ class FirebaseAppCheckWeb extends FirebaseAppCheckPlatform {
171171
_delegate!.idTokenChangedController?.close();
172172
},
173173
);
174-
_delegate!.onTokenChanged(app.name).listen((event) {
175-
_tokenChangesListeners[app.name]!.add(event.token.toDart);
176-
});
174+
_delegate!.onTokenChanged(app.name).listen(
175+
(event) {
176+
_tokenChangesListeners[app.name]!.add(event.token.toDart);
177+
},
178+
// Forward JS SDK errors (e.g. network failures during background
179+
// token refresh) to the broadcast controller instead of letting them
180+
// surface as unhandled zone errors. If nobody is listening on the
181+
// broadcast stream the error is silently dropped.
182+
onError: (Object error) {
183+
_tokenChangesListeners[app.name]?.addError(error);
184+
},
185+
);
177186
}
178187
}
179188

0 commit comments

Comments
 (0)