Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console output on empty reply message for service #195

Open
Niels-Be opened this issue Aug 17, 2018 · 1 comment
Open

console output on empty reply message for service #195

Niels-Be opened this issue Aug 17, 2018 · 1 comment

Comments

@Niels-Be
Copy link
Contributor

Niels-Be commented Aug 17, 2018

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

if (!Encoder::EncodeObject(reply_value, &iter, &siter)) {
printf("Failed to encode reply value\n");
}

This is because reply_value is undefined and EncodeObject returns false in that case.

node-dbus/src/encoder.cc

Lines 163 to 164 in 7c87b54

if (IsNullOrUndefined(value)) {
return false;

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
Copy link

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.

Niels-Be added a commit to Niels-Be/node-dbus that referenced this issue Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants