File tree 3 files changed +39
-0
lines changed
3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @firebase/auth " : patch
3
+ " firebase " : patch
4
+ ---
5
+
6
+ Fix issue with IndexedDB retry logic causing uncaught errors
Original file line number Diff line number Diff line change @@ -374,6 +374,12 @@ fireauth.storage.IndexedDB.prototype.withRetry_ = function(transaction) {
374
374
db . close ( ) ;
375
375
this . initPromise_ = undefined ;
376
376
return attempt ( resolve , reject ) ;
377
+ } ) . thenCatch ( ( error ) => {
378
+ // Make sure any errors caused by initializeDbAndRun_() or
379
+ // db.close() are caught as well and trigger a rejection. If at
380
+ // this point, we are probably in a private browsing context or
381
+ // environment that does not support indexedDB.
382
+ reject ( error ) ;
377
383
} ) ;
378
384
} ) ;
379
385
} ;
Original file line number Diff line number Diff line change @@ -413,6 +413,33 @@ function testIndexedDb_setGetRemove_connectionClosed() {
413
413
}
414
414
415
415
416
+ function testIndexedDb_failingOnDbOpen ( ) {
417
+ manager = getDefaultFireauthManager ( ) ;
418
+ manager . addStorageListener ( ( ) => {
419
+ fail ( 'Storage should not be triggered for local changes!' ) ;
420
+ } ) ;
421
+ let errorThrown = false ;
422
+ indexedDBMock . open = ( ) => {
423
+ throw new Error ( 'InvalidStateError: A mutation operation was attempted ' +
424
+ 'on a database that did not allow mutations.' ) ;
425
+ } ;
426
+ return goog . Promise . resolve ( )
427
+ . then ( ( ) => {
428
+ return manager . get ( 'key1' ) ;
429
+ } )
430
+ . thenCatch ( ( error ) => {
431
+ assertEquals (
432
+ error . message ,
433
+ 'InvalidStateError: A mutation operation was attempted on a ' +
434
+ 'database that did not allow mutations.' ) ;
435
+ errorThrown = true ;
436
+ } )
437
+ . then ( ( ) => {
438
+ assertTrue ( errorThrown ) ;
439
+ } ) ;
440
+ }
441
+
442
+
416
443
function testStartListeners ( ) {
417
444
manager = getDefaultFireauthManager ( ) ;
418
445
var listener1 = goog . testing . recordFunction ( ) ;
You can’t perform that action at this time.
0 commit comments