angular/packages/core/test/resource
Alex Rickabaugh b592b1b051 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
2025-02-05 15:01:02 -08:00
..
BUILD.bazel feat(core): experimental resource() API for async dependencies (#58255) 2024-10-21 13:25:58 -07:00
resource_spec.ts fix(core): fix race condition in resource() (#59851) 2025-02-05 15:01:02 -08:00