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 {
6565
6666/**
6767 * 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.
6870 */
6971function isWindowSupported ( ) : boolean {
7072 return (
Original file line number Diff line number Diff line change @@ -28,13 +28,19 @@ import {
2828 * @public
2929 */
3030export 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+ }
3138 // firebase-js-sdk/issues/2393 reveals that idb#open in Safari iframe and Firefox private browsing
3239 // might be prohibited to run. In these contexts, an error would be thrown during the messaging
3340 // instantiating phase, informing the developers to import/call isSupported for special handling.
3441 return (
3542 typeof window !== 'undefined' &&
3643 isIndexedDBAvailable ( ) &&
37- ( await validateIndexedDBOpenable ( ) ) &&
3844 areCookiesEnabled ( ) &&
3945 'serviceWorker' in navigator &&
4046 'PushManager' in window &&
You can’t perform that action at this time.
0 commit comments