viewprt
viewprt copied to clipboard
Gracefully recover from observer exceptions 🧸
Previously, when an exception was thrown no further updates would be able to get scheduled. This PR, adds a try/finally to ensure that the internal state is cleaned up correctly even when an exception gets thrown.
I initially tried to have the try/finally just in the call to check
, but PositionObserver has its own state that goes bad if an exception is thrown, which I ran into when writing the test. If you think there's a better way to test PositionObserver that doesn't trigger this behavior, I am open to suggestions.
Regarding deoptimizing the function, my understanding is that this is not much of an issue in modern JavaScript VMs. [Source: my husband]
I tried to make an internal “call” function that simply calls a user callback wrapped in a try but wasn’t continuing for some reason.