Ignore cache open insecure operation error (#1161)

This commit is contained in:
Abhinav Kumar 2023-06-05 12:40:36 +05:30 committed by GitHub
commit 374bb1aee5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,20 +1,32 @@
import { logError } from 'utils/sentry';
import { CacheStorageFactory } from './cacheStorageFactory';
const SecurityError = 'SecurityError';
const INSECURE_OPERATION = 'The operation is insecure.';
async function openCache(cacheName: string) {
try {
return await CacheStorageFactory.getCacheStorage().open(cacheName);
} catch (e) {
// log and ignore, we don't want to break the caller flow, when cache is not available
logError(e, 'openCache failed');
// ignoring insecure operation error, as it is thrown in incognito mode in firefox
if (e.name === SecurityError && e.message === INSECURE_OPERATION) {
// no-op
} else {
// log and ignore, we don't want to break the caller flow, when cache is not available
logError(e, 'openCache failed');
}
}
}
async function deleteCache(cacheName: string) {
try {
return await CacheStorageFactory.getCacheStorage().delete(cacheName);
} catch (e) {
// log and ignore, we don't want to break the caller flow, when cache is not available
logError(e, 'deleteCache failed');
// ignoring insecure operation error, as it is thrown in incognito mode in firefox
if (e.name === SecurityError && e.message === INSECURE_OPERATION) {
// no-op
} else {
// log and ignore, we don't want to break the caller flow, when cache is not available
logError(e, 'deleteCache failed');
}
}
}