Skip to content

Reject cache.invalidate() when Cloudflare refuses the purge - #18291

Open
danielmlr wants to merge 1 commit into
withastro:mainfrom
danielmlr:fix/cloudflare-purge-failure
Open

danielmlr wants to merge 1 commit into
withastro:mainfrom
danielmlr:fix/cloudflare-purge-failure

Conversation

@danielmlr

Copy link
Copy Markdown

Changes

  • Workers Cache reports a refused purge, including one over the rate limit, as success: false in the result of cache.purge() (docs). The provider dropped that result, so cache.invalidate() resolved and the pages stayed cached with nothing logged. Workers Cache purges always use the Free-tier limit of 5 per minute per account, with a bucket of 25 (limits), which a site that purges on every content save can reach.
  • The provider throws when success is false, with Cloudflare's errors as the error's cause, as invalidate() already does on Netlify when its purge request fails. Successful purges are unchanged. Callers that await invalidate() after a write start seeing rejections; EmDash is guarding its calls in fix(core): stop a failed cache purge from failing a saved write emdash-cms/emdash#3987.

Testing

  • New test/units/cache-purge.test.ts covers the purge step with a stand-in cache object, since cloudflare:workers does not load in Node: an accepted purge passes the tags through and resolves, a refused one rejects with the returned errors as cause.

Docs

  • None needed: the route caching guide does not describe what invalidate() does when a purge fails, for any provider.

Workers Cache reports a refused purge, such as one over the purge rate
limit, as `success: false` in the result of `cache.purge()`. The provider
discarded that result, so `cache.invalidate()` resolved although nothing
was purged. Throw instead, with the returned `errors` as the error's cause.
@changeset-bot

changeset-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 96e055f

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

This PR includes changesets to release 1 package
Name Type
@astrojs/cloudflare 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

@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label Oct 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant