mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
0bea6a9b19
Summary: See T55861104. In rare cases if `removeReactInstanceEventListener` is called right after (like, a small number of CPU instructions later, on a different thread) we allocate the `listeners` array with a certain size, then we could have one or more `null` listeners in the array, which is what we've been seeing in prod, at very low volumes, for several years. Without solving the root of the race condition we can just add a null check here. Maybe it's also possible that if `addReactInstanceEventListener` is called on another thread in a racey way, that the size will be incremented on the array before we can access the additional member. That seems crazy, but maybe. While this has been firing for multiple years it seems like a more recent change caused a regression. This diff doesn't address that and only resolves the crash. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D18192801 fbshipit-source-id: c1000cfcdf6f251b03061d1386eabb9f0617a7d3