1

I have a promise function which unfortunately do not occur an error.. It is the Modbus-serial package. When I disconnect the rs485 connection I do not get an error.

Now I want to fire an error after one second when I do not get a response from the modbus promise.

const errHandling = setTimeout(async () => {
  try {
    // return new Error("Whoops!");

    power = await hitachi.getFrequency();
    console.log();
    //clearTimeout(errHandling);
  } catch (e) {
    console.error(e);
  }
}, 500);
Michael Mitch
  • 403
  • 2
  • 7
  • 17
  • 1
    [NodeJS Timeout a Promise if failed to complete in time](https://stackoverflow.com/q/32461271) | https://italonascimento.github.io/applying-a-timeout-to-your-promises/ – VLAZ Nov 17 '20 at 15:47

0 Answers0