docs: document RenderOptions.waitUntil#13744
Conversation
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
|
Companion docs PR for withastro/astro#16187. Since this documents a new public option that is not released yet, this should likely follow the usual |
|
Hello! Thank you for opening your first PR to Astro’s Docs! 🎉 Here’s what will happen next:
|
ArmandPhilippot
left a comment
There was a problem hiding this comment.
Thanks for the fix and the docs! I left a few suggestions, especially around the code snippet, as I'm not sure if it's currently useful.
And, please use our PR template the next time.
|
|
||
| If not provided, Astro will fallback to its default behavior for fetching error pages. | ||
|
|
||
| #### `RenderOptions.waitUntil` |
There was a problem hiding this comment.
We use parentheses for functions:
| #### `RenderOptions.waitUntil` | |
| #### `RenderOptions.waitUntil()` |
| ```js "waitUntil" | ||
| return app.render(request, { | ||
| routeData, | ||
| locals, | ||
| waitUntil, | ||
| }); | ||
| ``` |
There was a problem hiding this comment.
I'm not sure the current example is really helpful because this only lists what is available in RenderOptions. Would something like the following would be correct as minimal example?
| ```js "waitUntil" | |
| return app.render(request, { | |
| routeData, | |
| locals, | |
| waitUntil, | |
| }); | |
| ``` | |
| ```js {8} | |
| import { createApp } from 'astro/app/entrypoint'; | |
| const app = createApp(); | |
| export async function handler(event, context) { | |
| // ... | |
| return app.render(event.request, { | |
| waitUntil: context.waitUntil.bind(context), | |
| }); | |
| } | |
| ``` |
|
|
||
| Adapters can pass this through to let runtime cache providers schedule work such as cache writes or stale-while-revalidate without blocking the response path. | ||
|
|
||
| The following example forwards a runtime's `waitUntil` implementation to [`app.render()`](#apprender): |
There was a problem hiding this comment.
See my suggestion for the code snippet:
| The following example forwards a runtime's `waitUntil` implementation to [`app.render()`](#apprender): | |
| The following example forwards a runtime's `waitUntil()` implementation to [`app.render()`](#apprender) in an [adapter server entrypoint](/en/reference/adapter-reference/#building-a-server-entrypoint): |
|
Thanks for the suggestions, that makes sense. I’ve applied the updates:
|
Description (required)
Documents the new
RenderOptions.waitUntil()option added by withastro/astro#16187.This explains how adapter authors can forward a runtime
waitUntil()hook toapp.render()so runtime cache providers can schedule background work without blocking the response.Related issues & labels (optional)
For Astro version:
6.2.0. See astro PR withastro/astro#16187.