diff --git a/lib/connection.js b/lib/connection.js index 6fc9d54f..8ebf6f34 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -77,7 +77,9 @@ Connection.prototype.callMethod = function( ) { const packet = this.createPacket('call', interfaceName, methodName, args); const packetId = packet.call[0]; - this._callbacks[packetId] = callback || common.doNothing; + this._callbacks[packetId] = callback || ((error) => { + if (error) this.emit('error', error); + }); this._send(packet); }; @@ -160,7 +162,12 @@ Connection.prototype.inspectInterface = function(interfaceName, callback) { this._callbacks[packetId] = (error, ...methods) => { if (error) { - return callback(error); + if (callback) { + callback(error); + } else { + this.emit('error', error); + } + return; } const proxy = new RemoteProxy(this, interfaceName, methods);