HomePhabricator
Diffusion Comm 6ca9199cd166

[native] Avoid calling invariant from worklet

Description

[native] Avoid calling invariant from worklet

Summary:
While working on testing D10553, I noticed the following error:

Screenshot 2024-01-05 at 9.55.20 AM.png (2×1 px, 1 MB)

This regression was caused by my changes in D10004. I added an invariant to satisfy Flow there, but I didn't consider that I was adding a function call to a worklet. Reanimated worklets can only call other functions that are worklets; otherwise, the call should be proxied via runOnJS.

This diff updates the call to just throw new Error instance, which works just as well for Flow. I'm not sure if using Error within a worklet will cause an issue, but it shouldn't matter because the control flow should never enter this conditional, and if it does then we're going to be erroring anyways.

Test Plan: Before this diff, swiping a message would trigger the error in the screenshot above. After this diff, the error is no longer triggered.

Reviewers: ginsu, atul, will

Reviewed By: atul, will

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D10554

Details

Provenance
ashoatAuthored on Jan 5 2024, 7:07 AM
Reviewer
atul
Differential Revision
D10554: [native] Avoid calling invariant from worklet
Parents
rCOMM1ded84f26e78: [web] Fix default apps
Branches
Unknown
Tags
Unknown