Skip to content

Commit

Permalink
Hardened retry behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason-Morcos committed Nov 27, 2023
1 parent 40294c2 commit b8831fb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/kumo-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ export class KumoApi {
} else {
this.log.warn('Kumo API: response error from device: %d %s',
response.status, response.statusText);
if(attempt_number < 2 && (await this.checkSecurityToken(true))) {
return this.directRequest(post_data, serial, attempt_number + 1);
}
return null;
}
} catch(error) {
Expand All @@ -483,8 +486,8 @@ export class KumoApi {
return null;
}

if (!data || data == '{ _api_error: \'device_authentication_error\' }') {
this.log.warn('Kumo API: error direct querying device: %s.', serial);
if(!data || '_api_error' in data) {
this.log.warn('Kumo API: error direct querying device: %s; %s.', serial, data);
if(attempt_number < 2 && (await this.checkSecurityToken(true))) {
return this.directRequest(post_data, serial, attempt_number + 1);
}
Expand Down

0 comments on commit b8831fb

Please sign in to comment.