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
FakeAsyncZone and RootZone used in conjunction can clobber interleaved timers of each other #54323
Comments
JiaLiPassion
added a commit
to JiaLiPassion/angular
that referenced
this issue
Feb 25, 2024
Close angular#54323 fakeAsync should use the same timerId pool with native, so they will not conflict.
JiaLiPassion
added a commit
to JiaLiPassion/angular
that referenced
this issue
Feb 25, 2024
Close angular#54323 fakeAsync should use the same timerId pool with native, so they will not conflict.
JiaLiPassion
added a commit
to JiaLiPassion/angular
that referenced
this issue
Mar 26, 2024
Close angular#54323 fakeAsync should use the same timerId pool with native, so they will not conflict.
JiaLiPassion
added a commit
to JiaLiPassion/angular
that referenced
this issue
Mar 26, 2024
Close angular#54323 fakeAsync should use the same timerId pool with native, so they will not conflict.
JiaLiPassion
added a commit
to JiaLiPassion/angular
that referenced
this issue
Mar 26, 2024
Close angular#54323 fakeAsync should use the same timerId pool with native, so they will not conflict.
ilirbeqirii
pushed a commit
to ilirbeqirii/angular
that referenced
this issue
Apr 6, 2024
…ngular#54600) Close angular#54323 fakeAsync should use the same timerId pool with native, so they will not conflict. PR Close angular#54600
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Which @angular/* package(s) are the source of the bug?
zone.js
Is this a regression?
Yes
Description
Currently, Zone.js patches
setTimeout
and keeps atasksByHandleId
map to keep atimerId
<->ZoneTask
relationship. This map appears to be global to each method per
window
(browser use case) /global
instance and not perZone
as it's defined onpatchTimer
.Tasks then use the return value from their schedule methods (such as
setTimeout
) to store this ID intasksByHandleId
. For example, in the case of a root zone with no wrapping it normally just callssetNative
which may invokesetTimeout
and we store the timer ID in the map. These IDs are monotonically increasing and therefore are never reused. However, in the case offake-async-test
it starts from1
and increments it's own counters per task.If you have a
Zone
that is usingsetNative
and scheduling using the real browser scheduler and usingfake-async-zone
it is possible to generate two tasks that are both pending with the same ID because they don't know of each other. For example:In the above psuedo-code, the task that runs in some other zone is overwritten with one that runs the
root
later because of the shared map. In contexts outside offake-async-test
, it's likely never going to happenbecause the IDs are strictly monotonically increasing. But in
fake-async-test
, this is troublesome because they can overlap which is bad news when using a single globaltasksByHandleId
Some thoughts:
I've not included a full reproduction yet because the exact specifics are kind of hard to encode but I will try and get something up.
Please provide a link to a minimal reproduction of the bug
N/A; coming soon maybe
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: