withastro/astro · info

data store cleared (force)

Error message

data store cleared (force)

What it means

With experimental.collectionStorage set to 'chunked' or { chunkSize }, the content-layer data store lives in a directory. When a sync force-clears the store it removes and recreates that directory, then logs this warning (domain 'content') so you know all stored collection data was discarded and will be rebuilt by the following sync. It is an expected consequence of a forced clear, not a fault.

Source

Thrown at packages/astro/src/core/sync/index.ts:105

 */
export async function clearContentLayerCache({
	settings,
	logger,
	fs = fsMod,
	isDev,
}: {
	settings: AstroSettings;
	logger: AstroLogger;
	fs?: typeof fsMod;
	isDev: boolean;
}) {
	if (getDataStoreChunkSize(settings) !== undefined) {
		const dataStore = getDataStoreDir(settings, isDev);
		if (fs.existsSync(dataStore)) {
			logger.debug('content', 'clearing data store');
			await fs.promises.rm(dataStore, { force: true, recursive: true });
			await fs.promises.mkdir(dataStore, { recursive: true });
			logger.warn('content', 'data store cleared (force)');
		}
	} else {
		const dataStore = getDataStoreFile(settings, isDev);
		if (fs.existsSync(dataStore)) {
			logger.debug('content', 'clearing data store');
			await fs.promises.rm(dataStore, { force: true });
			logger.warn('content', 'data store cleared (force)');
		}
	}
}

/**
 * Generates TypeScript types for all Astro modules. This sets up a `src/env.d.ts` file for type inferencing,
 * and defines the `astro:content` module for the Content Collections API.
 *
 * @experimental The JavaScript API is experimental
 */
export async function syncInternal({

View on GitHub (pinned to e294953aa8)

Solutions

  1. Treat it as informational — the next content sync repopulates the store from your loaders
  2. If the clear was unexpected, find what triggered the forced sync (config change, manual .astro deletion, loader error recovery)
  3. Stop deleting the data store directory in CI caches so syncs can reuse incremental state
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'node:fs';
const storeReady =
  existsSync('.astro/data-store.json') || existsSync('.astro/data-store');
if (!storeReady) {
  // run `astro sync` before relying on content data
}

Prevention

When it happens

Trigger: experimental.collectionStorage resolves to a chunk size and the data store directory exists when clearDataStore runs — e.g. corrupted store recovery, collectionStorage config changes, or a forced re-sync during dev.

Common situations: Adopting the experimental chunked collection storage; toggling between single-file and chunked modes; CI caches where the store directory is wiped between runs.

Related errors


AI-assisted analysis of withastro/astro@e294953aa8 (2026-08-18). Data as JSON: /api/errors/2acaf09778f12828. Report an issue: GitHub.