react-native-macos/Libraries/Interaction
Rob Walker 14042fb76f Don't crash when promise task is cancelled before its resolved (#29969)
Summary:
This pull request fixes a potential `TypeError` in TaskQueue.js, that happens if a promise is added to the task queue, which is cancelled between the promise starting and resolving.

The exact error this resolves is
```js
TypeError: TaskQueue: Error resolving Promise in task gen1: Cannot set property ‘popable’ of undefined
      167 |           queueStackSize: this._queueStack.length,
      168 |         });
    > 169 |       this._queueStack[stackIdx].popable = true;
          |                                              ^
      170 |       this.hasTasksToProcess() && this._onMoreTasks();
      171 |     })
      172 |     .catch(ex => {
      at Libraries/Interaction/TaskQueue.js:169:46
```

This specific error was also reported in https://github.com/facebook/react-native/issues/16321

## Changelog

[General] [Fixed] - Prevent TypeError in TaskQueue when cancelling a started but not resolved promise.

Pull Request resolved: https://github.com/facebook/react-native/pull/29969

Test Plan:
The added test demonstrates the error, if run without the fixed applied to TaskQueue.js.
This is a race condition error, so is difficult to replicate!

Reviewed By: yungsters

Differential Revision: D23785972

Pulled By: appden

fbshipit-source-id: ddb8d06b37d296ee934ff39815cf5c9026d73871
2020-09-25 19:21:56 -07:00
..
__tests__ Don't crash when promise task is cancelled before its resolved (#29969) 2020-09-25 19:21:56 -07:00
Batchinator.js Exact-by-default codemod for react-native-github 2019-11-21 09:42:57 -08:00
BridgeSpyStallHandler.js Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
FrameRateLogger.js Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
InteractionManager.js Migrate large amount of modules to flow strict and strict-local 2020-07-22 09:46:16 -07:00
InteractionMixin.js Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
InteractionStallDebugger.js Exact-by-default codemod for react-native-github 2019-11-21 09:42:57 -08:00
JSEventLoopWatchdog.js RN: Remove `fbjs/performanceNow` Dependency 2020-07-09 11:40:57 -07:00
NativeFrameRateLogger.js Migrate large amount of modules to flow strict and strict-local 2020-07-22 09:46:16 -07:00
PanResponder.js Exact-by-default codemod for react-native-github 2019-11-21 09:42:57 -08:00
TaskQueue.js Don't crash when promise task is cancelled before its resolved (#29969) 2020-09-25 19:21:56 -07:00
TouchHistoryMath.js Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00