Unhandled promise rejection when stopping the coordinator
See original GitHub issueHey, I encountered a bug today where my Node process exited due to an unhandled promise rejection and finally found out that stopping the coordinator was the cause.
Following code can reproduce the issue:
const {Controller} = require("zigbee-herdsman");
const coordinator = new Controller({
databasePath: 'test.db',
serialPort: {path: '/dev/ttyACM0'}
});
let date = new Date();
coordinator
.start()
.then(() => {
coordinator.stop()
.then(() => console.log("Stopped", new Date() - date))
.catch(err => console.log("Catch error (2):", new Date() - date, err));
console.log("Controller created", new Date() - date);
})
.catch(err => console.log("Catch error (1):", new Date() - date, err))
I added dates for debugging purposes but when the app crashes no error handler is invoked. I used my stopwatch and it takes 10 seconds to crash. Output:
Controller created 211
Stopped 319
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TIMEOUT".] {
code: 'ERR_UNHANDLED_REJECTION'
}
I tried to get the stack using the unhandled rejection event but it was undefined, I do not know where to search. It would be nice to restart the controller without terminating Node itself. I am using CC253X with DECONZ Adapter.
Maybe this information is helpful to debug the problem. If you have any further questions, let me know. I am using v0.14.40 and the test.db file had no previous devices in it.
Issue Analytics
- State:
- Created a year ago
- Comments:17 (16 by maintainers)
You can click the edit icon here: https://github.com/Koenkk/zigbee-herdsman/blob/master/src/adapter/deconz/driver/driver.ts (pencil) then make a pr
This looks good to me, could you make a pr?