From 237d49505cfa91d60cf31ef0b2c24a66220fb940 Mon Sep 17 00:00:00 2001 From: fkatsuhiro Date: Wed, 27 May 2026 14:34:08 +0900 Subject: [PATCH 1/4] feat: test add regression test for dev route cache issue --- packages/astro/test/dev-route-cache.test.ts | 40 +++++++++++++++++++ .../fixtures/hmr-route-cache/package.json | 8 ++++ .../hmr-route-cache/src/pages/[id].astro | 7 ++++ 3 files changed, 55 insertions(+) create mode 100644 packages/astro/test/dev-route-cache.test.ts create mode 100644 packages/astro/test/fixtures/hmr-route-cache/package.json create mode 100644 packages/astro/test/fixtures/hmr-route-cache/src/pages/[id].astro diff --git a/packages/astro/test/dev-route-cache.test.ts b/packages/astro/test/dev-route-cache.test.ts new file mode 100644 index 000000000000..00df95c8a7ed --- /dev/null +++ b/packages/astro/test/dev-route-cache.test.ts @@ -0,0 +1,40 @@ +import * as assert from 'node:assert/strict'; +import { after, before, describe, it } from 'node:test'; +import * as cheerio from 'cheerio'; +import { type DevServer, type Fixture, loadFixture } from './test-utils.ts'; + +// getStaticPaths() results were cached indefinitely during `astro dev`, +// so external data changes (e.g. headless CMS) were never reflected without restarting the dev server. +describe('dev: route cache is cleared between requests', () => { + let fixture: Fixture; + let devServer: DevServer; + + before(async () => { + fixture = await loadFixture({ root: './fixtures/hmr-route-cache/' }); + devServer = await fixture.startDevServer(); + }); + + after(async () => { + await devServer?.stop(); + }); + + it('re-runs getStaticPaths() on each request', async () => { + const res1 = await fixture.fetch('/test'); + assert.equal(res1.status, 200); + const time1 = Number.parseInt( + cheerio + .load(await res1.text())('#time') + .text(), + ); + await new Promise((r) => setTimeout(r, 10)); + const res2 = await fixture.fetch('/test'); + assert.equal(res2.status, 200); + const time2 = Number.parseInt( + cheerio + .load(await res2.text())('#time') + .text(), + ); + + assert.notEqual(time1, time2); + }); +}); diff --git a/packages/astro/test/fixtures/hmr-route-cache/package.json b/packages/astro/test/fixtures/hmr-route-cache/package.json new file mode 100644 index 000000000000..05219118a03b --- /dev/null +++ b/packages/astro/test/fixtures/hmr-route-cache/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/hmr-route-cache", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/hmr-route-cache/src/pages/[id].astro b/packages/astro/test/fixtures/hmr-route-cache/src/pages/[id].astro new file mode 100644 index 000000000000..d6e261ed2752 --- /dev/null +++ b/packages/astro/test/fixtures/hmr-route-cache/src/pages/[id].astro @@ -0,0 +1,7 @@ +--- +export async function getStaticPaths() { + return [{ params: { id: 'test' }, props: { callTime: Date.now() } }]; +} +const { callTime } = Astro.props; +--- +

{callTime}

From 339b697ec5a69ee876a76ee98ba7fd1f9105c2d1 Mon Sep 17 00:00:00 2001 From: fkatsuhiro Date: Thu, 28 May 2026 00:45:32 +0900 Subject: [PATCH 2/4] feat: clear cache getStaticPath --- packages/astro/src/vite-plugin-app/app.ts | 5 +++++ pnpm-lock.yaml | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/astro/src/vite-plugin-app/app.ts b/packages/astro/src/vite-plugin-app/app.ts index 0a401aff78e5..5e832449423f 100644 --- a/packages/astro/src/vite-plugin-app/app.ts +++ b/packages/astro/src/vite-plugin-app/app.ts @@ -182,6 +182,11 @@ export class AstroServerApp extends BaseApp { const self = this; await self.#loadFetchHandler(); + // Clear the route cache on every dev request so that getStaticPaths() + // re-runs when external data (e.g. a headless CMS) changes between requests. + // This mirrors the per-request behavior that existed before v6.3.0. + //self.clearRouteCache(); + self.pipeline.clearRouteCache(); let handled = true; await runWithErrorHandling({ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0ca8c9a01909..84810211e8c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3190,6 +3190,12 @@ importers: specifier: workspace:* version: link:../../.. + packages/astro/test/fixtures/hmr-content-api: + dependencies: + astro: + specifier: workspace:* + version: link:../../.. + packages/astro/test/fixtures/hmr-markdown: dependencies: astro: @@ -3202,6 +3208,12 @@ importers: specifier: workspace:* version: link:../../.. + packages/astro/test/fixtures/hmr-route-cache: + dependencies: + astro: + specifier: workspace:* + version: link:../../.. + packages/astro/test/fixtures/hmr-slots-render: dependencies: astro: From 1c46a5b8e30704b22dddd9694e55c40e0e95071a Mon Sep 17 00:00:00 2001 From: fkatsuhiro Date: Fri, 29 May 2026 20:31:57 +0900 Subject: [PATCH 3/4] refacter: some comentouts --- packages/astro/src/vite-plugin-app/app.ts | 2 -- pnpm-lock.yaml | 6 ------ 2 files changed, 8 deletions(-) diff --git a/packages/astro/src/vite-plugin-app/app.ts b/packages/astro/src/vite-plugin-app/app.ts index 5e832449423f..ff282dd200bb 100644 --- a/packages/astro/src/vite-plugin-app/app.ts +++ b/packages/astro/src/vite-plugin-app/app.ts @@ -184,8 +184,6 @@ export class AstroServerApp extends BaseApp { await self.#loadFetchHandler(); // Clear the route cache on every dev request so that getStaticPaths() // re-runs when external data (e.g. a headless CMS) changes between requests. - // This mirrors the per-request behavior that existed before v6.3.0. - //self.clearRouteCache(); self.pipeline.clearRouteCache(); let handled = true; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 84810211e8c4..73169eb52a8b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3190,12 +3190,6 @@ importers: specifier: workspace:* version: link:../../.. - packages/astro/test/fixtures/hmr-content-api: - dependencies: - astro: - specifier: workspace:* - version: link:../../.. - packages/astro/test/fixtures/hmr-markdown: dependencies: astro: From 30b0904a296d617048ac8fe7f33deb19839cb552 Mon Sep 17 00:00:00 2001 From: fkatsuhiro Date: Fri, 29 May 2026 20:45:07 +0900 Subject: [PATCH 4/4] feat: changeset file --- .changeset/full-ties-add.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/full-ties-add.md diff --git a/.changeset/full-ties-add.md b/.changeset/full-ties-add.md new file mode 100644 index 000000000000..f261c0bf5fd4 --- /dev/null +++ b/.changeset/full-ties-add.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixed an issue where the API fetch in the frontmatter was not triggered when modifying external CMS content while the development server was running.