diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index 8bd93dd2..5b0c1d65 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -286,7 +286,7 @@ class EmbarkController { engine.startService("namingSystem"); engine.startService("console"); engine.startService("pluginCommand"); - engine.events.on('check:backOnline:Ethereum', () => callback()); + engine.events.once('check:backOnline:Ethereum', () => callback()); }, function ipcConnect(callback) { // Do specific work in case we are connected to a socket: diff --git a/lib/core/events.js b/lib/core/events.js index 6b34c0b4..5a3ab0a8 100644 --- a/lib/core/events.js +++ b/lib/core/events.js @@ -19,6 +19,7 @@ function log(eventType, eventName) { EventEmitter.prototype._maxListeners = 350; const _on = EventEmitter.prototype.on; +const _once = EventEmitter.prototype.once; const _setHandler = EventEmitter.prototype.setHandler; EventEmitter.prototype.on = function(requestName, cb) { @@ -27,6 +28,12 @@ EventEmitter.prototype.on = function(requestName, cb) { return _on.call(this, requestName, cb); }; +EventEmitter.prototype.once = function(requestName, cb) { + log("listening to event (once): ", requestName); + warnIfLegacy(requestName); + return _once.call(this, requestName, cb); +}; + EventEmitter.prototype.setHandler = function(requestName, cb) { log("setting handler for: ", requestName); warnIfLegacy(requestName);