Skip to content

Commit

Permalink
fix(miio): One failing message should not kill the process 20 minutes…
Browse files Browse the repository at this point in the history
… later
  • Loading branch information
Hypfer committed Feb 16, 2021
1 parent 3e23678 commit e5fd0a5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/miio/RetryWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RetryWrapper {

this.state = STATES.HANDSHAKING;

return await new Promise((resolve, reject) => { //TODO: uhm? return await new promise?
return new Promise((resolve, reject) => {
this.loopHandshake(() => {
resolve();
});
Expand Down Expand Up @@ -116,16 +116,13 @@ class RetryWrapper {

options.retries = options.retries !== undefined ? options.retries : 0;

if (options.retries > 10000) {
setTimeout(() => {
// Since the service automatically restarts after exiting, this
// could help fixing things I'm missing now
Logger.error("Unable to reach vacuum");

process.exit(1);
}, 150); //Suicide after throwing so that the exception can still be handled further up
if (options.retries > 100) {
Logger.error("Unable to reach vacuum. Giving up after 100 tries");

//Maybe resetting the ID helps?
this.miioSocket.nextId = 0;

//Throw this further up instead of retrying
throw new MiioTimeoutError(msg);
}

Expand Down

0 comments on commit e5fd0a5

Please sign in to comment.