fix(core): not all callbacks running when registered at the same time#56981
fix(core): not all callbacks running when registered at the same time#56981crisbeto wants to merge 1 commit intoangular:mainfrom
Conversation
There was a problem hiding this comment.
Note: the assumption here is that we'll always run through all the phases in their defined order once, before we run other phases. E.g. we can't have two read calls in a row before first hitting an earlyRead for a setup like afterRender({read: fn, earlyRead: fn}). I think that's true based on the code that executes them, but it's worth calling out.
There was a problem hiding this comment.
Somewhat of a tangent: one thing we discussed just now is how this behaves w.r.t. an exception in one of the phases. Currently I believe this would continue to run the subsequent phases, passing the resulting state of the phase that ran prior to the one that threw an exception (based on how pipelinedArgs is updated after the callback has executed).
I wonder if we should cancel all subsequent callbacks in case of an exception, effectively dropping callbacksLeftToRun to 0 to let it clean up. It probably makes sense for afterRender to have similar behavior so that would need some sort of a different approach.
The above is kind of out of scope because this PR makes things clearly more correct than what we have today, but it would be beneficial to have tests for the behavior in the presence of exceptions.
There was a problem hiding this comment.
Yeah agreed that it would make more sense that the chain gets interrupted if one of the callbacks throws, although the current behavior seems quite deliberate to me (reading the code). Maybe @devknoll has context on it?
Fixes that only the first callback was firing when multiple are registered in the same call to `afterNextRender`, e.g. `afterNextRender({earlyRead: fn, read: fn});`
Fixes angular#56979.
7e07c44 to
175f040
Compare
|
This PR was merged into the repository by commit e504ad9. The changes were merged into the following branches: main, 18.1.x |
|
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. |
Fixes that only the first callback was firing when multiple are registered in the same call to
afterNextRender, e.g.afterNextRender({earlyRead: fn, read: fn});Fixes #56979.