Shouqun / node-dbus

dbus module for node
MIT License
150 stars 70 forks source link

console output on empty reply message for service #195

Open Niels-Be opened 6 years ago

Niels-Be commented 6 years ago

If a service method has no return value an message is printed on stdout.

https://github.com/Shouqun/node-dbus/blob/7c87b54cb5a107e6b3d3c610cc1f64cd2d26c4ec/src/object_handler.cc#L88-L90

This is because reply_value is undefined and EncodeObject returns false in that case. https://github.com/Shouqun/node-dbus/blob/7c87b54cb5a107e6b3d3c610cc1f64cd2d26c4ec/src/encoder.cc#L163-L164

Since the error is ignored anyways and it works just fine, a solution might be just to return true in that case. However I don't know the impact on other code. So maybe just do the check before even calling Encoder::EncodeObject in ObjectHandler::_SendMessageReply.

Let me know what to do and I can submit an PR.

Example that causes this output:

const DBusService = DBus.registerService('system', null);
const DBusObject = DBusService.createObject("/org/node/bluez");
const DBusInterface = DbusObject.createInterface('org.bluez.Profile1');

DBusInterface.addMethod('NewConnection', { in: [{
        type: 'o',
        name: 'device'
    }, {
        type: 'h',
        name: 'fd'
    }, {
        type: 'a{sv}',
        name: 'fd_properties'
    }]
}, (device, fd, options, callback) => {
    console.log("New Connection for " + device);
    callback(); // will print "Failed to encode reply value"
});
ARitz-Cracker commented 5 years ago

Hey, is this going to be looked at? I'd rather not have modules pollute my stdout, and create useless log entries. I understand that not being able to encode a response is an issue and should be reported, but empty replies are features, features which some daemons expect, like bluetoothd. I'd rather not train myself to ignore messages like these in case I actually am making a mistake.