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(astro): always return cloned content collection #11228

Merged
merged 2 commits into from
Jun 10, 2024
Merged

fix(astro): always return cloned content collection #11228

merged 2 commits into from
Jun 10, 2024

Conversation

ascorbic
Copy link
Contributor

Changes

Currently, the first time getCollection is called in prod it returns the same array that is then cached, meaning that any mutations are applied to the cached value. Subsequent calls return a clone of the cached value (so these can be safely changed), but any changes made on the first call are still present. The original bug was fixed in #8022, but it missed the issue with the first invocation. This PR ensures that the array is always cloned before returning.

Fixes #10700

Testing

Adds a test fixture based on the #10700 repro. Thanks @SStembridge.

Docs

Copy link

changeset-bot bot commented Jun 10, 2024

🦋 Changeset detected

Latest commit: b19eb77

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 the pkg: astro Related to the core `astro` package (scope) label Jun 10, 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.

Congrats on your first core PR @ascorbic ! 🥳

Might as well start you off on the right foot! Just made a small suggestion to the changeset for your consideration to give you a taste of what you're gonna get from me going forward... 😄

Welcome to core! 💜

.changeset/early-melons-thank.md Outdated Show resolved Hide resolved
@ascorbic ascorbic changed the title fix: always return cloned content collection fix(astro): always return cloned content collection Jun 10, 2024
@ascorbic ascorbic merged commit 1e293a1 into main Jun 10, 2024
14 checks passed
@ascorbic ascorbic deleted the plt-2182 branch June 10, 2024 19:57
@astrobot-houston astrobot-houston mentioned this pull request Jun 10, 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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prod build collections cache can be modified
3 participants