Skip to content

Commit

Permalink
fix: prioritize command failure over command timeout (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
samrum committed May 28, 2021
1 parent 0d7286c commit 14e7ebc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/RequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ class RequestService {

const requestTimestamp = new Date(requestTime).getTime();

if (status === CommandResponseStatus.failure) {
throw new RequestError("Command Failure")
.setResponse(response)
.setRequest(request);
}

if (
Date.now() >=
requestTimestamp + this.requestPollingTimeoutSeconds * 1000
Expand All @@ -374,11 +380,7 @@ class RequestService {
.setRequest(request);
}

if (status === CommandResponseStatus.failure) {
throw new RequestError("Command Failure")
.setResponse(response)
.setRequest(request);
} else if (
if (
status === CommandResponseStatus.inProgress &&
type !== "connect"
) {
Expand All @@ -388,6 +390,7 @@ class RequestService {
.setMethod(RequestMethod.Get)
.setUpgradeRequired(false)
.setCheckRequestStatus(checkRequestStatus);

return this.sendRequest(request);
}

Expand Down

0 comments on commit 14e7ebc

Please sign in to comment.