Merge pull request #1008 from balena-io/fix-bad-report

Don't drop failed api patch data
This commit is contained in:
CameronDiver 2019-06-20 05:25:11 -07:00 committed by GitHub
commit d8eeba3d46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -501,24 +501,27 @@ export class APIBinder {
); );
} }
await Bluebird.resolve( try {
this.sendReportPatch(stateDiff, { apiEndpoint, uuid }), await Bluebird.resolve(
) this.sendReportPatch(stateDiff, { apiEndpoint, uuid }),
.catch(StatusError, (e: StatusError) => { ).timeout(conf.apiTimeout);
this.stateReportErrors = 0;
_.assign(this.lastReportedState.local, stateDiff.local);
_.assign(this.lastReportedState.dependent, stateDiff.dependent);
} catch (e) {
if (e instanceof StatusError) {
// We don't want this to be classed as a report error, as this will cause // We don't want this to be classed as a report error, as this will cause
// the watchdog to kill the supervisor - and killing the supervisor will // the watchdog to kill the supervisor - and killing the supervisor will
// not help in this situation // not help in this situation
log.error( log.error(
`Non-200 response from API! Status code: ${e.statusCode} - message: ${ 'Non-200 response from the API! Status code: ${e.statusCode} - message:',
e.message e,
}`,
); );
}) } else {
.timeout(conf.apiTimeout); throw e;
}
this.stateReportErrors = 0; }
_.assign(this.lastReportedState.local, stateDiff.local);
_.assign(this.lastReportedState.dependent, stateDiff.dependent);
} }
private reportCurrentState(): null { private reportCurrentState(): null {