Skip to content

Document new FetchState methods - #14476

Open
matthewp wants to merge 6 commits into
mainfrom
fetch-state-docs
Open

Document new FetchState methods#14476
matthewp wants to merge 6 commits into
mainfrom
fetch-state-docs

Conversation

@matthewp

Copy link
Copy Markdown
Contributor

Description (required)

Documents new FetchState methods added in withastro/astro#17708

References

withastro/astro#17708

@astrobot-houston

astrobot-houston commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/reference/modules/astro-fetch.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

Preview deployment

✅ Deployment complete!

@ArmandPhilippot ArmandPhilippot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, Matthew! I left a few nits, but otherwise this looks good to me. I'm only confused with state.finalize() (see my comment).

Comment thread src/content/docs/en/reference/modules/astro-fetch.mdx Outdated
Comment thread src/content/docs/en/reference/modules/astro-fetch.mdx Outdated
<Since v="7.3.0" />
</p>

Applies the response finalizers registered with [`state.addResponseFinalizer()`](#stateaddresponsefinalizer) and returns the resulting response. Call this after your last response handler when composing a pipeline from individual handlers instead of `astro()`:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The description seems okay to me, but then I'm confused looking at the code snippet: you say "Applies the response finalizers registered with state.addResponseFinalizer()" but the code snippet doesn't show that.

So I wonder: does state.finalize() work without addResponseFinalizer()? Or should the code snippet include addResponseFinalizer() to better illustrate the use of finalize()?

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.

It just returns the same response if you don't have any finalizers. But the idea is that anything that has the FetchState can add a finalizer, so you want to run this even if you didn't add one yourself. I can add an one to the example of that helps to clarify though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, thanks for the explanation!

If finalize() is useless without addResponseFinalizer() (ie. same response), I think the description is fine (no need to say they can call it, but it does nothing...). But, yes, I think it might be helpful for users to see a "real" use case with addResponseFinalizer().

@ArmandPhilippot ArmandPhilippot added add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" = approved for merging on release day. labels Aug 27, 2026
@ArmandPhilippot ArmandPhilippot added this to the 7.3 milestone Aug 27, 2026
matthewp and others added 2 commits August 27, 2026 16:21
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
Co-authored-by: Armand Philippot <git@armand.philippot.eu>

@ArmandPhilippot ArmandPhilippot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So, apart from my last nit and the code snippet which I think could be improved to help users (still a nit that said: better to have one than nothing at all), everything LGTM! Thanks, again.

Comment thread src/content/docs/en/reference/modules/astro-fetch.mdx Outdated
Comment thread src/content/docs/en/reference/modules/astro-fetch.mdx Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" = approved for merging on release day.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants