viewprt icon indicating copy to clipboard operation
viewprt copied to clipboard

Gracefully recover from observer exceptions 🧸

Open ZeeJab opened this issue 5 years ago • 2 comments

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.

ZeeJab avatar Dec 09 '19 14:12 ZeeJab

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]

ZeeJab avatar Dec 11 '19 13:12 ZeeJab

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.

gpoitch avatar Dec 11 '19 13:12 gpoitch