Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix send / remove timing bug in Dispatcher #6756

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/util/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down