Skip to content

Commit 6444b34

Browse files
authored
fix(replay): Better session storage check (#8547)
Apparently accessing sessionStorage in an iframe with certain permissions can result in a throw, so we try-catch this to ensure we do not produce any errors. Closes #8392
1 parent c2b1bfd commit 6444b34

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/replay/src/util/hasSessionStorage.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@ import { WINDOW } from '../constants';
22

33
/** If sessionStorage is available. */
44
export function hasSessionStorage(): boolean {
5-
return 'sessionStorage' in WINDOW && !!WINDOW.sessionStorage;
5+
try {
6+
// This can throw, e.g. when being accessed in a sandboxed iframe
7+
return 'sessionStorage' in WINDOW && !!WINDOW.sessionStorage;
8+
} catch {
9+
return false;
10+
}
611
}

0 commit comments

Comments
 (0)