File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @firebase/messaging ' : patch
3
+ ---
4
+
5
+ Fix uncaught rejection in ` isSupported() ` if environment does not support IndexedDB's ` open() ` method.
Original file line number Diff line number Diff line change @@ -65,6 +65,8 @@ export function isSupported(): boolean {
65
65
66
66
/**
67
67
* Checks to see if the required APIs exist.
68
+ * Unlike the modular version, it does not check if IndexedDB.open() is allowed
69
+ * in order to keep isSupported() synchronous and maintain v8 compatibility.
68
70
*/
69
71
function isWindowSupported ( ) : boolean {
70
72
return (
Original file line number Diff line number Diff line change @@ -28,13 +28,19 @@ import {
28
28
* @public
29
29
*/
30
30
export async function isWindowSupported ( ) : Promise < boolean > {
31
+ try {
32
+ // This throws if open() is unsupported, so adding it to the conditional
33
+ // statement below can cause an uncaught error.
34
+ await validateIndexedDBOpenable ( ) ;
35
+ } catch ( e ) {
36
+ return false ;
37
+ }
31
38
// firebase-js-sdk/issues/2393 reveals that idb#open in Safari iframe and Firefox private browsing
32
39
// might be prohibited to run. In these contexts, an error would be thrown during the messaging
33
40
// instantiating phase, informing the developers to import/call isSupported for special handling.
34
41
return (
35
42
typeof window !== 'undefined' &&
36
43
isIndexedDBAvailable ( ) &&
37
- ( await validateIndexedDBOpenable ( ) ) &&
38
44
areCookiesEnabled ( ) &&
39
45
'serviceWorker' in navigator &&
40
46
'PushManager' in window &&
You can’t perform that action at this time.
0 commit comments