From caa4a40d3d7cfaba3f501e3b36f474e32e76b9d7 Mon Sep 17 00:00:00 2001 From: Matt Sprague Date: Tue, 29 May 2018 15:30:44 -0700 Subject: [PATCH] Fix send / remove timing bug in Dispatcher --- src/util/dispatcher.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/dispatcher.js b/src/util/dispatcher.js index b2f3b9b0adc..855b276c3a3 100644 --- a/src/util/dispatcher.js +++ b/src/util/dispatcher.js @@ -50,6 +50,10 @@ class Dispatcher { * @returns The ID of the worker to which the message was sent. */ send(type: string, data: mixed, callback?: ?Function, targetID?: number): number { + if (this.actors.length === 0) { + // an async send call is getting executed but remove has been called + return -1; + } if (typeof targetID !== 'number' || isNaN(targetID)) { // Use round robin to send requests to web workers. targetID = this.currentActor = (this.currentActor + 1) % this.actors.length;