Fix: catch sessionStorage errors for large documents (#6150)

This commit is contained in:
shamoon authored and GitHub committed 2024-03-21 06:31:25 -07:00
1 parent 8c9fe4da06
commit ebe1479503
3 files changed
+22 -6

No files matched your search

+4 -1
View File
@@ -76,7 +76,10 @@ const mock = () => {
let storage: { [key: string]: string } = {}
return {
getItem: (key: string) => (key in storage ? storage[key] : null),
setItem: (key: string, value: string) => (storage[key] = value || ''),
setItem: (key: string, value: string) => {
if (value.length > 1000000) throw new Error('localStorage overflow')
storage[key] = value || ''
},
removeItem: (key: string) => delete storage[key],
clear: () => (storage = {}),
}