diff --git a/plugins/plugin-search/src/node/prepareSearchIndex.ts b/plugins/plugin-search/src/node/prepareSearchIndex.ts index 94691768..d5965982 100644 --- a/plugins/plugin-search/src/node/prepareSearchIndex.ts +++ b/plugins/plugin-search/src/node/prepareSearchIndex.ts @@ -92,7 +92,8 @@ export async function onSearchIndexRemoved( const locale = page.pathLocale const index = getIndexByLocale(locale, searchOptions) const cache = getIndexCache(fileId) - index.removeAll(cache) + if (cache && cache.length) + index.removeAll(cache) await writeTemp(app) } }