Merge pull request #2099 from knandersen/bugfix/2085

Fix #2085 by handling discarded hub commands
This commit is contained in:
Kevin Nørby Andersen 2019-04-08 19:27:32 -04:00 committed by GitHub
commit 03b4d0e582
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -943,8 +943,9 @@ class Boost {
const motor = this.motor(portID);
if (motor) {
motor._status = feedback;
if (feedback === (BoostPortFeedback.COMPLETED ^ BoostPortFeedback.IDLE) &&
motor.pendingPromiseFunction) {
// Makes sure that commands resolve both when they actually complete and when they fail
const commandCompleted = feedback & (BoostPortFeedback.COMPLETED ^ BoostPortFeedback.DISCARDED);
if (commandCompleted && motor.pendingPromiseFunction) {
motor.pendingPromiseFunction();
}
}