construct-style-sheets
construct-style-sheets copied to clipboard
If an adopter disconnects in between animation frames, it throws an error during restyling
While callers of restyleAdopter
check if their adopters are connected, restyleAdopter
contains a call to requestAnimationFrame
which means that adopters can be disconnected while the browser is waiting for the next repaint.
Here's the error that is thrown under those circumstances:
.
This error bubbles up as an unhandled exception in certain apps (like in this NextJS setup):
, as well as in the console.
The fix is to take into account that nodes may become disconnected in the callback of requestAnimationFrame
. With this update, I can no longer repro this race condition.
@calebdwilliams would appreciate any feedback or a review for this fix!
@jorgea-stripe looks like the tests failed.
@calebdwilliams - I believe my latest change should fix the test that broke due to an outdated browser message! (I've run it locally however I don't have permission to run on the CI)