construct-style-sheets icon indicating copy to clipboard operation
construct-style-sheets copied to clipboard

If an adopter disconnects in between animation frames, it throws an error during restyling

Open jorgea-stripe opened this issue 2 years ago • 3 comments

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: image.

This error bubbles up as an unhandled exception in certain apps (like in this NextJS setup): image, 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.

jorgea-stripe avatar Jun 21 '22 22:06 jorgea-stripe

@calebdwilliams would appreciate any feedback or a review for this fix!

jorgea-stripe avatar Jun 22 '22 00:06 jorgea-stripe

@jorgea-stripe looks like the tests failed.

calebdwilliams avatar Jun 22 '22 12:06 calebdwilliams

@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)

jorgea-stripe avatar Jun 23 '22 07:06 jorgea-stripe