konsumer / tplink-lightbulb

Control TP-Link smart lightbulbs from nodejs
MIT License
190 stars 32 forks source link

Script hangs on fail. #53

Closed kareltucek closed 3 years ago

kareltucek commented 3 years ago

Hi!

If the command (e.g., turning light bulb on) fails (e.g., because network interface is unreachable), tplight does not exit. Instead, it remains hanging around forever.

For instance:

$ tplight on 10.0.0.0
Error: send EACCES 10.0.0.0:9999
    at doSend (dgram.js:683:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:323:12)
    at afterDns (dgram.js:629:5)
    at processTicksAndRejections (internal/process/task_queues.js:85:21) {
  errno: 'EACCES',
  code: 'EACCES',
  syscall: 'send',
  address: '10.0.0.0',
  port: 9999
}
konsumer commented 3 years ago

I think this will need testing but it has to do with promise-catching. For example, here is the catch for "on".

I think something like this would work:

.catch(err => {
  console.error(err)
  process.exit(1)
})
kareltucek commented 3 years ago

Thanks for reply and sorry for so late reply on my part!

I think something like this would work:

Yes I do confirm that this solves the problem.

konsumer commented 3 years ago

Should be resolved in 1.5.4