Skip to content

waitUntil not available in onRequest context in a CacheProvider #16145

Description

@edmelly

Astro Info

Astro                    v6.1.1
Vite                     v7.3.1
Node                     v24.14.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare (v13.1.4)
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

experimental.cache: waitUntil missing from CacheProvider.onRequest context when using the Cloudflare adapter.

The docs define onRequest context as:

context: { request: Request; url: URL; waitUntil?: (promise: Promise<unknown>) => void }

But waitUntil is missing in both the type and at runtime when using the Cloudflare adapter.

dist/core/cache/types.d.tswaitUntil is not in the type:

onRequest?(context: {
  request: Request;
  url: URL;
}, next: MiddlewareNext): Promise<Response>;

Runtimetypeof context.waitUntil is "undefined" inside a custom provider's onRequest.

Without it, cache writes in Cloudflare Workers must be awaited before the response is sent, adding latency on every cache miss. The correct pattern — context.waitUntil(cache.put(...)) — is currently broken.

What's the expected result?

context.waitUntil should be available, matching the documented signature, so that cache writes can be handed off as background work.

Link to Minimal Reproducible Example

https://github.com/edmelly/astro-playground

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: astroRelated to the core `astro` package (scope)pkg: cloudflareRelated to the Cloudflare adapter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions