Conversation
Queue reducer actions that arrive before the first commit and flush them after the provider mounts, so useSuspense of an already-resolved endpoint can retry when React restarts DataProvider. Co-authored-by: Nathaniel Tucker <me@ntucker.me>
🦋 Changeset detectedLatest commit: 88e1542 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Benchmark React
Details
| Benchmark suite | Current: 88e1542 | Previous: a76996a | Ratio |
|---|---|---|---|
data-client: getlist-100 |
135.14 ops/s (± 4.6%) |
125 ops/s (± 4.8%) |
0.92 |
data-client: getlist-500 |
43.86 ops/s (± 3.4%) |
39.84 ops/s (± 5.5%) |
0.91 |
data-client: update-entity |
333.33 ops/s (± 9.4%) |
312.5 ops/s (± 7.2%) |
0.94 |
data-client: update-user |
303.03 ops/s (± 7.6%) |
294.12 ops/s (± 7.8%) |
0.97 |
data-client: getlist-500-sorted |
42.93 ops/s (± 9.7%) |
43.39 ops/s (± 9.2%) |
1.01 |
data-client: update-entity-sorted |
294.12 ops/s (± 5.8%) |
263.16 ops/s (± 5.9%) |
0.89 |
data-client: update-entity-multi-view |
322.58 ops/s (± 8.1%) |
277.78 ops/s (± 7.0%) |
0.86 |
data-client: list-detail-switch-10 |
10.41 ops/s (± 10.6%) |
7.22 ops/s (± 5.2%) |
0.69 |
data-client: update-user-10000 |
67.57 ops/s (± 15.3%) |
71.43 ops/s (± 12.4%) |
1.06 |
data-client: invalidate-and-resolve |
36.77 ops/s (± 5.9%) |
32.95 ops/s (± 5.6%) |
0.90 |
data-client: unshift-item |
200 ops/s (± 4.6%) |
188.68 ops/s (± 5.9%) |
0.94 |
data-client: delete-item |
270.27 ops/s (± 6.2%) |
250 ops/s (± 4.4%) |
0.93 |
data-client: move-item |
161.33 ops/s (± 9.9%) |
158.77 ops/s (± 8.3%) |
0.98 |
This comment was automatically generated by workflow using github-action-benchmark.
Contributor
|
Size Change: +217 B (+0.21%) Total Size: 103 kB 📦 View Changed
ℹ️ View Unchanged
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
useSuspenseof an endpoint that is already resolved can stay on its fallback when that response is dispatched beforeDataProviderhas committed. React restarts the provider, the update is dropped, and a freshNetworkManagerrefetches in a loop. A slow endpoint misses this because its response arrives after commit.Solution
Until the store's first commit,
usePromisifiedDispatchrecords reducer actions and returns the same commit promise it returns today. It does not call React's dispatch. A layout effect flushes that queue in order. The passive effect does not resolve the promise on the mount snapshot, so listeners see the reducer state after the flush commits. After that first effect, dispatches go straight to React.Fetching still starts during render.
NetworkManager.idleCallbackis unchanged. This does not re-resolve a fetch that was delivered to a provider React discarded. Amanagersarray kept outsideDataProvidercan still leave Suspense on the fallback in that case.Open questions
N/A