[f] Fix for #971 - "Fatal error when Ethereum node going offline".

[a] Added .once() into Events.
This commit is contained in:
hodlbank 2018-10-08 23:41:38 +00:00 committed by Pascal Precht
parent 08c140b035
commit f41bcd55d6
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 8 additions and 1 deletions

View File

@ -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:

View File

@ -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);