Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: throw error if rewrite is attempted after body is used #11258

Merged
merged 2 commits into from
Jun 14, 2024
Merged

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Jun 14, 2024

Changes

Experimental Astro.rewrite() clones the request, which throws a confusing error if the body has already been consumed. This PR detects this and throws a more helpful error instead.

Fixes #11247

Testing

Adds tests

Docs

@withastro/maintainers-docs This adds a new Astro error

Copy link

changeset-bot bot commented Jun 14, 2024

🦋 Changeset detected

Latest commit: 2e7605f

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

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 pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Jun 14, 2024
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Thanks @ascorbic ! Advice looks clear and helpful to the reader! 🙌

Tiny suggestions for your consideration below!

.changeset/healthy-oranges-report.md Outdated Show resolved Hide resolved
packages/astro/src/core/errors/errors-data.ts Outdated Show resolved Hide resolved
packages/astro/src/core/errors/errors-data.ts Outdated Show resolved Hide resolved
Co-authored-by: Sarah Rainsberger <[email protected]>
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Awesome fix, thank you Matt!

@ascorbic ascorbic merged commit d996db6 into main Jun 14, 2024
13 checks passed
@ascorbic ascorbic deleted the plt-2196 branch June 14, 2024 12:57
@astrobot-houston astrobot-houston mentioned this pull request Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Experimental rewriting of POST request does not work (reopened)
4 participants