Skip to content

Commit cf134d9

Browse files
committed
fix: catch error during cache clear on startup
1 parent b9a031f commit cf134d9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/runtime/server/plugin.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ export default defineNitroPlugin(async nitro => {
4747
const rootRedirect = resolveRootRedirect(runtimeI18n.rootRedirect)
4848
const _defaultLocale: string = runtimeI18n.defaultLocale || ''
4949

50-
// clear cache for i18n handlers on startup
51-
const cacheStorage = useStorage('cache')
52-
const cachedKeys = await cacheStorage.getKeys('nitro:handlers:i18n')
53-
await Promise.all(cachedKeys.map(key => cacheStorage.removeItem(key)))
50+
// attempt to clear cache for i18n handlers on startup
51+
try {
52+
const cacheStorage = useStorage('cache')
53+
const cachedKeys = await cacheStorage.getKeys('nitro:handlers:i18n')
54+
await Promise.all(cachedKeys.map(key => cacheStorage.removeItem(key)))
55+
} catch {}
5456

5557
const detection = useI18nDetection(undefined)
5658
const cookieOptions = {

0 commit comments

Comments
 (0)