cheery / node-udev

Bindings to libudev
35 stars 31 forks source link

The event handler fails to print out exception messages #23

Open cheery opened 7 years ago

cheery commented 7 years ago

In a related pull request, we may have spotted a bug. The bug causes the exceptions to be ignored silently inside the event handler.

To illustrate the problem, here's an example:

var util = require("util");
var udev = require("./udev.js");

var monitor = udev.monitor();
monitor.on('add', function (device) {
    console.log(device.DEVPATH + " added");
    throw new Error("Trycatch?");
});

The above example should result in an error logged, similar to the following program:

setTimeout(function(){
    console.log("timeout");
    throw new Error("Trycatch?");
}, 1);

There should be a handler in Node.js runtime that implements the behavior, it should be added into on_handle_event to resolve this issue.