-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): fix race condition in resource() (#59851)
The refactoring of `resource()` to use `linkedSignal()` introduced the potential for a race condition where resources would get stuck and not update in response to a request change. This occurred under a specific condition: 1. The request changes while the resource is still in loading state 2. The resource resolves the previous load before its `effect()` reacts to the request change. In practice, the window for this race is small, because the request change in (1) will schedule the effect in (2) immediately. However, it's easier to trigger this sequencing in tests, especially when one resource depends on the output of another. To fix the race condition, the resource impl is refactored to track the request in its state, and ignore resolved values or streams for stale requests. This refactoring actually makes the resource code simpler and easier to follow as well. Fixes #59842 PR Close #59851
- Loading branch information
Showing
5 changed files
with
157 additions
and
83 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.