From b55a1499da99acf44629ef9aeadcd6405be5ad66 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Mon, 23 Dec 2024 13:25:23 +0000 Subject: [PATCH] fix: wait for content layer sync before starting dev server --- .changeset/mighty-pugs-retire.md | 5 +++ packages/astro/src/content/content-layer.ts | 4 +- packages/astro/src/core/dev/dev.ts | 42 ++++++++++----------- 3 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 .changeset/mighty-pugs-retire.md diff --git a/.changeset/mighty-pugs-retire.md b/.changeset/mighty-pugs-retire.md new file mode 100644 index 000000000000..8520213a4d32 --- /dev/null +++ b/.changeset/mighty-pugs-retire.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes race condition where dev server would attempt to load collections before the content had loaded diff --git a/packages/astro/src/content/content-layer.ts b/packages/astro/src/content/content-layer.ts index 4e7d364841e7..44c81f48586b 100644 --- a/packages/astro/src/content/content-layer.ts +++ b/packages/astro/src/content/content-layer.ts @@ -173,11 +173,11 @@ export class ContentLayer { shouldClear = true; } - if (currentConfigDigest && previousConfigDigest !== currentConfigDigest) { + if (previousConfigDigest && previousConfigDigest !== currentConfigDigest) { logger.info('Content config changed'); shouldClear = true; } - if (process.env.ASTRO_VERSION && previousAstroVersion !== process.env.ASTRO_VERSION) { + if (previousAstroVersion && previousAstroVersion !== process.env.ASTRO_VERSION) { logger.info('Astro version changed'); shouldClear = true; } diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index 0af637164735..1ac6691e381c 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -84,27 +84,6 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise