Skip to content

fix(core): invalidate Node route caches after background publishing - #4889

Merged
swissky merged 8 commits into
mainfrom
emdash-bot/issue-4887
Nov 30, 2026
Merged

swissky merged 8 commits into
mainfrom
emdash-bot/issue-4887

Conversation

@emdash-autofix

Copy link
Copy Markdown
Contributor

What does this PR do?

Reuses Astro's active cache handle on long-lived Node runtimes so plugin content actions from hooks and cron invalidate the same cache as plugin routes. Scheduled publishing falls back to that invalidator, including timer-driven sweeps, publishScheduled(), and runScheduledTasks(); explicit platform onPublished callbacks keep precedence.

This addresses cached home/category listings and articles remaining stale after background publication. Constructing another memory provider would clear a separate cache, so the runtime retains the handle supplied by an actual request. Invalidation remains process-local; other Node instances still retain their own entries. No general-purpose purge API is added.

Updates route-caching documentation and adds an emdash patch changeset.

Scope: plugin enrichment is covered when the plugin publishes after updating. This does not change ctx.content.update cache behavior or hook invalidation on Cloudflare.

Type of change

  • Bug fix
  • Feature (requires an accepted feature plan or RFC)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Your connection to this change

Project-operated autofix bot working on the reported bug through auto-intake, under the AI policy's bot exemption. Maintainer review and approval are required before merge.

  • I use EmDash and ran into the problem this PR addresses
  • I maintain a tool, dependency, or service that EmDash uses, and this change concerns that integration
  • A Maintainer approved this specific change before I opened the PR

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (not applicable: no admin UI changes)
  • I have added and reviewed the user-facing changeset
  • New features link to their merged design PR (not applicable: bug fix)
  • I have included screenshots below if this PR changes the UI (not applicable)

AI assistance disclosure

AI-generated implementation, tests, and PR text using OpenAI GPT-5.5 and the delegated helper tool. Human maintainer approval is required before merge.

Screenshots / test output

Not applicable: no UI changes.

Verified:

  • pnpm build
  • pnpm typecheck
  • pnpm lint:quick — zero diagnostics
  • pnpm format
  • pnpm --dir docs build
  • Targeted Vitest runs — 159 tests passed across 7 files, covering background route-cache invalidation, plugin action settlement, Node scheduled driver, middleware prerender behavior, request-less runtime access, and scheduled publishing.

The regression reproduced a cached listing remaining a HIT after a scheduled publication before the fix. Tests use a real SQLite runtime and Astro's real memory provider, checking collection/entry invalidation while unrelated cached pages remain hits. Additional coverage checks disabled/absent caches, prerender and non-timer platforms, missing/failing invalidators, and explicit callback precedence. Full type-aware lint and the full test suite are left to CI.

AI assistance disclosure

  • This PR includes AI-generated code or text — model/tool: cloudflare-ai-gateway:gpt-6.1-sol via the EmDash bot (Pi Durable)

Closes #4887

The EmDash bot took this issue on automatically when it was opened; no maintainer has assigned it yet.

Bind the active Astro route-cache handle to long-lived Node runtimes for plugin hook/cron publication, and use it as the scheduled publishing fallback while preserving explicit platform callbacks. Added real-memory-provider regressions, failure-path coverage, updated route-cache docs, and an emdash patch changeset. Verified pnpm build, pnpm typecheck, pnpm lint:quick (zero diagnostics), pnpm format, docs build, and 159 targeted tests across seven files. Independent review found no blocking issues.

EmDash-Bot-Case: 1198246700-issue-6426352206
EmDash-Bot-Candidate: cand-1-856b65e264
@emdash-autofix emdash-autofix Bot added the bot:fix Assign this issue or pull request to the EmDash bot to fix label Nov 16, 2026
@emdash-autofix

emdash-autofix Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

EmDash bot: Closed

Plan

Ready for maintainer approval and merge: required checks pass on 6d728c7, the latest review is clean, and the branch merges cleanly. The reporter confirmed scheduled-cache invalidation on production Node with PostgreSQL 16; no further…

  • Inspect Node scheduler, plugin actions, and route cache integration
  • Add background invalidation and regression coverage
  • Run focused checks, review the diff, and submit
  • Tighten the comment and middleware test claims
  • Verify real Astro cache invalidation after a request ends
  • Run focused checks and submit the follow-up
  • Resolve middleware conflict and verify merged behavior
  • Merge installed-plugin refresh changes and verify

Status

  • The pull request or issue was closed.

Next action: None.

Details
Candidate cand-8-bf221e3288 (tree 3ffa336a759c)
Published head 6d728c7406cb
Reviewer's latest review of head approved
Reporter confirmation confirmed
Human approval required before merge

Required checks on the current head:

  • Typecheck: succeeded
  • Tests: succeeded
  • Smoke Tests: succeeded
  • Browser Tests: succeeded
  • Format: succeeded
  • CLAssistant: succeeded
  • Measure: succeeded

This status is generated from recorded evidence. It is not a review and contains no instructions.

@changeset-bot

changeset-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6d728c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-test Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
create-emdash Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach is sound. It fills the existing pluginContentCacheInvalidator slot on long-lived Node/Bun hosts from the request's context.cache, so invalidation hits the cache Astro actually serves. It does not construct a separate provider. Scheduled publishing uses that invalidator as the fallback onPublished, and an explicit callback still takes precedence. Both reviewers approved and found no blocking issues. Invalidation failures remain non-fatal, Cloudflare behaviour is unchanged, and no new per-request queries are added. One reviewer ran no code (static review only). The other noted that Astro's per-request handle was not confirmed to keep delegating to the shared provider after its request ends. Two non-blocking suggestions remain: trimming a justification-style comment in the middleware, and a middleware unit test that asserts less than its title claims.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

Comment thread packages/core/src/astro/middleware.ts Outdated
Comment on lines +294 to +296
// Reuse Astro's active provider: constructing another memory provider
// would invalidate a separate, empty cache. Only long-lived runtimes
// may retain this handle beyond the request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] Most of this comment explains an alternative the PR rejected ("constructing another memory provider would invalidate a separate, empty cache"). That justification is aimed at reviewers rather than future readers (see AGENTS.md comment discipline). The part worth keeping is the lifetime constraint:

Suggested change
// Reuse Astro's active provider: constructing another memory provider
// would invalidate a separate, empty cache. Only long-lived runtimes
// may retain this handle beyond the request.
// Only long-lived runtimes may retain the request's cache handle beyond the request.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trimmed this to the lifetime constraint as suggested.

Comment on lines +124 to +144
const entries = new Map([["posts:post-1", "cached"]]);
const cache = {
enabled: true,
invalidate: vi.fn(async ({ tags }: { tags: string[] }) => {
for (const tag of tags) entries.delete(tag);
}),
};
const context = createContext({ cache, path });
if (path === "/") {
(globalThis as Record<symbol, unknown>)[SETUP_VERIFIED_KEY] = true;
}

expect((await onRequest(context as never, async () => new Response("ok"))).status).toBe(200);
expect(mockSetInvalidator).toHaveBeenCalledOnce();

const invalidator = mockSetInvalidator.mock.calls[0]?.[0] as (
tags: string[],
) => Promise<void>;
await invalidator(["posts:post-1"]);
expect(cache.invalidate).toHaveBeenCalledWith({ tags: ["posts:post-1"] });
expect(entries.has("posts:post-1")).toBe(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] This test can't fail on a real regression. cache.invalidate is a mock that deletes from a local entries map, and the test then asserts that the mock deleted from that map. The only real assertion is that the bound closure forwards { tags } to cache.invalidate. The title ("keeps the request cache usable after the request ends") claims more than that, because a hand-written mock can't show that Astro's per-request handle keeps working after the request. I'd drop the entries map, rename the test to describe the forwarding it actually checks, and cover the after-request behaviour with an end-to-end test through a real Astro request context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed—the map only tested the mock. Removed it and renamed the test to describe the forwarding it actually checks. The separate integration test continues to cover eviction through Astro's real memory provider.

I also checked Astro's AstroCache.invalidate: it delegates directly to the stored provider and does not access request state. I'm leaving a full production-server lifetime regression out of this follow-up: the current browser fixture runs astro dev, where route caching is disabled, so that needs a production-mode harness rather than another synthetic context.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://emdash-bot-issue-4887.try.emdashcms.com, https://emdash-bot-issue-4887-emdash-playground.emdash-cms.workers.dev (commit 95b29af)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Cancelled 🚫

View logs ↗
6d728c7 2026-11-30T18:09:01.528Z View logs ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://800f57c3.try.emdashcms.com, https://800f57c3-emdash-playground.emdash-cms.workers.dev 95b29af 2026-11-21T16:06:49.660Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://946e2938.try.emdashcms.com, https://946e2938-emdash-playground.emdash-cms.workers.dev eb7f2fb 2026-11-19T12:22:12.800Z Visit the dashboard ↗
  • Build: In progress 🔵

View logs ↗
dbc386d 2026-11-19T12:10:13.734Z View logs ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://476690b0.try.emdashcms.com, https://476690b0-emdash-playground.emdash-cms.workers.dev 6050cbe 2026-11-18T06:33:24.360Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://7010ff91.try.emdashcms.com, https://7010ff91-emdash-playground.emdash-cms.workers.dev 6c72965 2026-11-18T06:22:52.412Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://6fd197e4.try.emdashcms.com, https://6fd197e4-emdash-playground.emdash-cms.workers.dev b90a0d1 2026-11-16T17:35:15.315Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://9df8954b.try.emdashcms.com, https://9df8954b-emdash-playground.emdash-cms.workers.dev c89e31b 2026-11-16T17:24:07.841Z Visit the dashboard ↗

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs 6d728c7 Nov 30 2026, 05:57 PM

@pkg-pr-new

pkg-pr-new Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@4889

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@4889

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@4889

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@4889

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@4889

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@4889

emdash

npm i https://pkg.pr.new/emdash@4889

create-emdash

npm i https://pkg.pr.new/create-emdash@4889

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@4889

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@4889

@emdash-cms/plugin-test

npm i https://pkg.pr.new/@emdash-cms/plugin-test@4889

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@4889

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@4889

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@4889

@emdash-cms/registry-loader

npm i https://pkg.pr.new/@emdash-cms/registry-loader@4889

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@4889

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@4889

upgrade-emdash

npm i https://pkg.pr.new/upgrade-emdash@4889

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@4889

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@4889

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@4889

@emdash-cms/plugin-ai-search

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-search@4889

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@4889

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@4889

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@4889

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@4889

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@4889

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@4889

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@4889

commit: 6d728c7

Address review suggestions: shorten the middleware comment to its lifetime constraint, remove the mock-only eviction map assertion, and rename the middleware test to describe forwarding rather than real Astro request lifetime. Verified 13 focused tests, pnpm format, and pnpm lint:quick with zero diagnostics. Independent review found no blocking defects. Production-server lifecycle coverage is deferred and disclosed.

EmDash-Bot-Case: 1198246700-issue-6426352206
EmDash-Bot-Candidate: cand-2-838ffd7999

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach is sound. On long-lived Node/Bun hosts, the middleware fills the existing pluginContentCacheInvalidator slot from the request's context.cache, so invalidation hits the cache Astro actually serves rather than a separate provider. Scheduled publishing uses that invalidator as the fallback onPublished, and an explicit callback still takes precedence. Both reviewers approved, and neither raised new findings. Both earlier suggestions are resolved: the middleware comment is trimmed to the lifetime constraint, and the unit test is renamed to describe the forwarding it actually checks. Invalidation failures stay non-fatal, Cloudflare behaviour is unchanged, and no new per-request queries are added. Reviewers ran no tests or builds. A full production-server after-request lifetime regression remains unverified. The author reasonably deferred it because the browser fixture runs astro dev, where route caching is disabled.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

Merge default branch 643443f and resolve the middleware conflict, preserving anonymous-render/rewrite reuse and active cache binding in both request initialization paths. Clarify docs to enumerate plugin methods that invalidate and explicitly exclude create/update. Verified workspace build and typecheck, formatting, quick lint (zero diagnostics), docs build, eight targeted test files, and a final 38-test cache/rewrite run. Follow-up review found all findings addressed and no new defects.

EmDash-Bot-Case: 1198246700-issue-6426352206
EmDash-Bot-Candidate: cand-3-8437fda77f

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach is sound. On long-lived Node/Bun hosts, the middleware fills the existing pluginContentCacheInvalidator slot from the request's context.cache, so invalidation reaches the cache Astro actually serves instead of a separately built provider. Scheduled publishing uses that invalidator as the fallback onPublished, and an explicit callback still takes precedence. Both reviewers approved and raised no new findings. Both earlier suggestions are resolved: the middleware comment is trimmed to the lifetime constraint, and the unit test is renamed to describe the forwarding it checks. Invalidation failures stay non-fatal, Cloudflare behaviour is unchanged, and no new per-request queries are added. Neither reviewer ran tests or builds. A production-server regression test for reusing the cache handle after the request ends is still missing. The author reasonably deferred it because the browser fixture runs astro dev, where route caching is disabled.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

Merge default branch f585c35 and resolve middleware conflict while preserving installed-plugin refresh, anonymous rewrite scope reuse, and active cache binding. Expose normalized publicPath from the page-signal helper so the merged plugin refresh logic works. Tighten scheduler comment and clarify Cloudflare hook guarantees. Verified workspace build/typecheck, format, zero-diagnostic quick lint, docs build, and 193 targeted tests across eight files; final review found no blockers.

EmDash-Bot-Case: 1198246700-issue-6426352206
EmDash-Bot-Candidate: cand-4-eb03418a04

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach is sound. On long-lived Node/Bun hosts, the middleware stores the request's context.cache handle in the existing pluginContentCacheInvalidator slot, so invalidation reaches the cache Astro actually serves. Scheduled publishing uses that invalidator as the fallback onPublished, and an explicit callback still takes precedence. Both reviewers approved and raised no findings. Cloudflare, astro dev and prerendered requests are unchanged, invalidation failures stay non-fatal, and no new per-request queries are added. Both earlier suggestions (the trimmed middleware comment and the renamed unit test) remain resolved. A production-server regression test for reusing the cache handle after the request ends is still missing. The author reasonably deferred it because the browser fixture runs astro dev, where route caching is disabled. Neither reviewer ran tests or builds.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

@emdash-autofix

Copy link
Copy Markdown
Contributor Author

CI's two Cloudflare failures are editor assertions (block deep-link expansion and saved image display). Both passed together locally against the Cloudflare fixture on this head; Node E2E and the other CI lanes passed. I requested a rerun of shard 3.

A maintainer needs to rerun Cloudflare E2E shard (2/8): GitHub refused the bot's request with HTTP 403. The aggregate Tests failure is only downstream of Cloudflare E2E, not a separate test failure.

@danielmlr danielmlr mentioned this pull request Nov 18, 2026
11 of 22 tasks
@emdash-autofix emdash-autofix Bot added the triage/verified Reporter verified the fix label Nov 19, 2026
Merge default branch 01f717d and resolve route-caching documentation conflicts, retaining new media-cache caveats and corrected Node scheduled/plugin publication guidance. No background-publish code behavior changed. Verified workspace build/typecheck, format, quick lint (zero diagnostics), docs build, and eight targeted test files. Reporter confirmed production Node scheduled invalidation with PostgreSQL 16. Independent review found no blockers.

EmDash-Bot-Case: 1198246700-issue-6426352206
EmDash-Bot-Candidate: cand-5-6d6af0becb

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach is sound: on long-lived Node/Bun hosts the middleware reuses Astro's active context.cache handle. The scheduled-publishing fallback keeps explicit onPublished precedence, and invalidation failures stay non-fatal. Neither reviewer found a runtime correctness issue, and both reviews were static with no tests or builds run. One finding needs fixing: the shared invalidator also enables Node media purges, and the route-caching docs still describe those as unsupported. Only openai/gpt-6.1-sol raised this; anthropic/claude-opus-5-5 reviewed the docs and found nothing to flag. The deferred production-server lifetime regression test is still missing, and both reviewers accepted that deferral.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

);
if (virtualCreateScheduler && cache?.enabled) {
// The timer scheduler needs the active provider's cache handle outside requests.
instance.setPluginContentCacheInvalidator((tags) => cache.invalidate({ tags }));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[needs fixing] Binding this shared invalidator also enables Node media purges, not just content-action purges: invalidatePluginMedia() falls back to this.pluginContentCacheInvalidator, and runSystemCleanupIfDue() passes it into runSystemCleanup(). However, the updated route-caching page still lists plugin hook/cron media deletes and hourly cleanup on Node under “Some deletes are not purged” (route-caching.mdx:95–97). Those statements become false for Node deployments with a compatible media cache provider once this binding has run. Update the media section to describe that coverage and its initialization/process-local limits, while retaining the separate warning that memoryCache() does not automatically cache media. (Raised by openai/gpt-6.1-sol only; anthropic/claude-opus-5-5 said the docs matched the behaviour.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed both consumers of the shared invalidator. Updated the media section and changeset to cover Node hook/cron image deletes and hourly cleanup after a route-cache-enabled request accesses the runtime. The docs explain the per-process binding and provider-dependent cross-instance behavior, remove the obsolete Node exclusions, and retain the warning that memoryCache() does not automatically cache media. Docs build, quick lint, and 66 focused cache/media tests pass.

Correct docs and changeset for the shared invalidator's existing Node media-purge effect: hook/cron media deletes and hourly cleanup purge removed images after a non-prerendered route-cache-enabled request accesses the runtime. Document initialization and provider-dependent cross-instance limits consistently for content/media, remove obsolete Node exclusions, and retain memoryCache's automatic-media-caching warning. No runtime code changed. Verified docs build, format, zero-diagnostic quick lint, and 66 focused tests; follow-up review found all findings addressed.

EmDash-Bot-Case: 1198246700-issue-6426352206
EmDash-Bot-Candidate: cand-6-3b621b2d9f

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach is sound. On long-lived Node/Bun hosts, the middleware reuses Astro's active context.cache handle to purge outside requests, and scheduled publishing falls back to it only when no explicit onPublished is passed. Both reviewers approved and neither raised new findings. The earlier findings are resolved: the route-caching docs and changeset now cover Node hook/cron media deletes and hourly cleanup, the mock-only test is renamed to describe the forwarding it checks, and the middleware comment is trimmed to the lifetime constraint. A regression test for the handle's lifetime on a real production server is still deferred. The author explained that the browser fixture runs astro dev, where route caching is disabled, so it needs a production-mode harness, and both reviewers accepted that. Both reviews were static, with no tests or builds run.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

@swissky

swissky commented Nov 21, 2026

Copy link
Copy Markdown
Member

@emdash-autofix This branch has conflicts that must be resolved docs/src/content/docs/deployment/route-caching.mdx

@emdash-autofix

Copy link
Copy Markdown
Contributor Author

@swissky Resolved the route-caching docs conflict, preserving the latest Cloudflare cron-purge warning and cacheable-404 guidance alongside the Node fix. Build, typecheck, docs build, quick lint, and 11 focused test files pass. Publishing the updated merge now.

Merge default branch 2084e51 and resolve maintainer-reported route-caching documentation conflicts. Preserve the latest Cloudflare cron-purge reliability warning, positive-maxAge/cacheable-404 guidance, and all Node content/media invalidation caveats. Clarify plugin create/update/delete remain non-purging. No runtime behavior changed during conflict resolution. Verified workspace build/typecheck, format, zero-diagnostic quick lint, docs build, 11 focused test files, and a final 13-test background-cache run. Follow-up review is clean.

EmDash-Bot-Case: 1198246700-issue-6426352206
EmDash-Bot-Candidate: cand-7-bb7cf395b0

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach is sound. On long-lived Node/Bun runtimes, the middleware reuses Astro's active context.cache handle so request-less purges (scheduled publishing, plugin content actions, media deletes, hourly cleanup) reach the same cache. Scheduled publishing falls back to it only when no explicit onPublished is passed. Both reviewers approved with no new findings. The earlier findings are resolved: the media docs and changeset now cover Node hook/cron deletes and hourly cleanup, the mock-only test is renamed to describe the forwarding it checks, and the middleware comment is trimmed to the lifetime constraint. A regression test for the handle's lifetime on a real production server is still deferred, because the browser fixture runs astro dev, where route caching is disabled. Both reviewers accepted that. Both reviews were static, with no tests or builds run.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

@swissky
swissky enabled auto-merge (squash) November 21, 2026 16:05
@emdash-autofix

Copy link
Copy Markdown
Contributor Author

Cloudflare E2E is green after the rerun. The remaining blocker is Test Shard (2/4). I reproduced that shard on this head with PostgreSQL 17.12: 236 files passed, 3,723 tests passed, 3 skipped.

I need a maintainer to provide the failing Vitest summary or rerun that unit shard directly. The available CI log tool exposes only the tail, which is entirely PostgreSQL teardown output—even at its 1,000-line limit. GitHub first refused the rerun with HTTP 403; the tool now reports a later failed run without giving its check ID. I haven't changed code without knowing the failing assertion.

Merge default branch ebc9fcd and resolve route-caching docs conflict, retaining Node scheduled/plugin publish invalidation and the new EmDashWorker requirement for effective Cloudflare cron purges. No runtime behavior changed during this merge. Verified workspace build/typecheck, format, zero-diagnostic quick lint, docs build, 11 focused core test files, and 18 Cloudflare scheduled-worker tests. Follow-up review found no blockers.

EmDash-Bot-Case: 1198246700-issue-6426352206
EmDash-Bot-Candidate: cand-8-bf221e3288

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach is sound. On long-lived Node/Bun runtimes, the middleware keeps Astro's active context.cache handle, so request-less purges reach the same cache provider that served pages. These purges come from scheduled publishing, plugin content actions, media deletes and hourly cleanup. Scheduled publishing uses the handle only when no explicit onPublished is passed. Both reviewers approved with no new findings. The earlier findings stay resolved: the media docs and changeset cover Node hook/cron deletes and hourly cleanup, the mock-only test was renamed to describe the forwarding it checks, and the middleware comment was trimmed to the lifetime constraint. A production-server regression test for the handle's lifetime is still deferred, because the browser fixture runs astro dev, where route caching is disabled. Both reviewers accepted that deferral. Both reviews were static, with no tests or builds run.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

@swissky
swissky merged commit e4c9baa into main Nov 30, 2026
64 of 65 checks passed
@swissky
swissky deleted the emdash-bot/issue-4887 branch November 30, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core area/docs bot:fix Assign this issue or pull request to the EmDash bot to fix cla: signed size/L triage/verified Reporter verified the fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node: scheduled publishing and plugin publishes from hooks/cron do not purge the route cache

1 participant