software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.59k stars 1.26k forks source link

Name every worklet function #6163

Open tjzel opened 6 days ago

tjzel commented 6 days ago

Summary

Currently, in case of unnamed worklets, such as

() => {
  'worklet';
  // some logic
}

function () {
  'worklet'
  // some logic
}

Those functions are named anonymous and parsed as such on the Worklet Runtime. However, this is a pitfall for Reanimated. When the anonymous function crashes and the stack trace is vague - it usually is, especially in production - the first suspicion is the error in Reanimated's core logic, since we don't know which function in particular has failed.

In case of a faulty logic in a third-party library this is double as harmful. It doesn't lead the creators of these libraries into the pit of success, since they might not be aware it's their code causing issues. Conversely, Reanimated maintainers receive a very obscure issue and engage in rather unpleasant debugging process - only to discover later the library's fault.

Test plan