Skip to content

edmelly/astro-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

astro-cache-waituntil-repro

Minimal reproduction for a missing waitUntil on the CacheProvider onRequest context.

Bug

The route caching docs describe the onRequest context as:

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

However, waitUntil is:

  1. Missing from the type definition in node_modules/astro/dist/core/cache/types.d.ts:

    onRequest?(context: {
      request: Request;
      url: URL;
      // waitUntil is not here
    }, next: MiddlewareNext): Promise<Response>;
  2. Absent at runtimetypeof context.waitUntil logs as "undefined" inside the provider.

This matters for Cloudflare Workers, where cache writes should be handed off via waitUntil so they don't block the response being sent to the client.

Versions

  • astro: 6.1.1
  • @astrojs/cloudflare: 13.1.4

Steps to reproduce

npm i
npm run build
npm run preview

Open or curl your preview, and check the Wrangler console output for:

[repro] typeof context.waitUntil = undefined

Expected

typeof context.waitUntil should be "function".

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages