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

Short-circuit the store cache from uncached stores #2605

Merged
merged 5 commits into from
Dec 2, 2023

Conversation

stephencelis
Copy link
Member

1.5 introduced the store tree, which works well when the entire tree is cached, but can produce invalid stores when an uncached store caches a child store and is then reinitialized. While folks upgrading to 1.5 should be in a good state, adopting the new scope operator can introduce this problem. To mitigate, we should only cache from the root to nodes as far as the cache resolves.

This is a temporary limitation to avoid breaking existing apps. We should be able to remove this workaround when uncached scopes are fully deprecated and removed from the library.

@stephencelis stephencelis added the store tree Related to our store tree release. label Dec 1, 2023
Comment on lines +40 to +45
childStore.send(.tap)
XCTAssertEqual(3, grandparentStore.withState(\.child.child.count))
XCTAssertEqual(3, childStore.withState(\.count))
grandparentStore.send(.incrementGrandchild)
XCTAssertEqual(4, grandparentStore.withState(\.child.child.count))
XCTAssertEqual(4, childStore.withState(\.count))
Copy link
Member Author

Choose a reason for hiding this comment

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

Both childStore assertions fail on 1.5.0...main.

@stephencelis stephencelis marked this pull request as ready for review December 2, 2023 01:20
@stephencelis stephencelis merged commit cf0f2f2 into main Dec 2, 2023
5 checks passed
@stephencelis stephencelis deleted the cache-short-circuit branch December 2, 2023 16:24
cgrindel-self-hosted-renovate bot referenced this pull request in cgrindel/rules_swift_package_manager Dec 5, 2023
…ure to from: "1.5.1" (#782)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
|
[pointfreeco/swift-composable-architecture](https://togithub.com/pointfreeco/swift-composable-architecture)
| patch | `from: "1.5.0"` -> `from: "1.5.1"` |

---

### Release Notes

<details>
<summary>pointfreeco/swift-composable-architecture
(pointfreeco/swift-composable-architecture)</summary>

###
[`v1.5.1`](https://togithub.com/pointfreeco/swift-composable-architecture/releases/tag/1.5.1)

[Compare
Source](https://togithub.com/pointfreeco/swift-composable-architecture/compare/1.5.0...1.5.1)

#### What's Changed

- Fixed: `BindingAction`'s case key path extraction was broken, which
could lead to actions received through effects to not be testable,
*.e.g* `\.binding.$text` would fail to match `.binding(.set(\.$text,
"Blob"))`. This has been fixed
([https://github.com/pointfreeco/swift-composable-architecture/pull/2600](https://togithub.com/pointfreeco/swift-composable-architecture/pull/2600)).
- Fixed: Store caching introduced in 1.5 could lead to a regression in
which a child store becomes "detached" when an uncached parent is
deinitialized. This has been fixed by only caching child stores when its
parents are cached
([https://github.com/pointfreeco/swift-composable-architecture/pull/2605](https://togithub.com/pointfreeco/swift-composable-architecture/pull/2605)).
- Fixed: `NavigationStackStore`'s internal use of `@StateObject` could
lead to broken navigation. By using an `@ObservedObject` instead we now
avoid this bug
([https://github.com/pointfreeco/swift-composable-architecture/pull/2599](https://togithub.com/pointfreeco/swift-composable-architecture/pull/2599)).
- Infrastructure: Fixed typo in 1.5 migration guide (thanks
[@&#8203;Ryu0118](https://togithub.com/Ryu0118),
[https://github.com/pointfreeco/swift-composable-architecture/pull/2595](https://togithub.com/pointfreeco/swift-composable-architecture/pull/2595);
thanks [@&#8203;yimajo](https://togithub.com/yimajo),
[https://github.com/pointfreeco/swift-composable-architecture/pull/2606](https://togithub.com/pointfreeco/swift-composable-architecture/pull/2606));
update documentation links in README (thanks
[@&#8203;woxtu](https://togithub.com/woxtu),
[https://github.com/pointfreeco/swift-composable-architecture/pull/2598](https://togithub.com/pointfreeco/swift-composable-architecture/pull/2598));

**Full Changelog**:
pointfreeco/swift-composable-architecture@1.5.0...1.5.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDAuMCIsInVwZGF0ZWRJblZlciI6IjM2LjEwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
store tree Related to our store tree release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants