AprilSylph / XKit-Rewritten

🧰 The enhancement suite for Tumblr's new web interface
GNU General Public License v3.0
274 stars 44 forks source link

Mutations util: Isolate callback errors #1512

Open marcustyphoon opened 1 week ago

marcustyphoon commented 1 week ago

Description

Wraps callbacks passed to the mutations util in try-catch so they don't impact each other when they throw.

See https://github.com/AprilSylph/XKit-Rewritten/issues/1508.

Function could, essentially equivalently, be const isolateErrors = async func => func(), basically as a more-self-documenting #1509—if anything I think in some browsers and circumstances that actually makes the error log better, compared to console.error, if I recall correctly.

Testing steps

You know... I'm not sure of a great way to reliably trigger the scenario to test this? I can maybe hack something together to ensure that modifiers get called in a certain order to demonstrate the problem. The place I ran into it was createCaughtUpLine throwing with a null input, per #1488, and breaking the boring tag chiclets tweak.