remove listeners to avoid leaks
This commit is contained in:
parent
2efea55d2b
commit
1b6ac99ea2
|
@ -33,6 +33,7 @@ class Test {
|
||||||
this.contracts = {};
|
this.contracts = {};
|
||||||
this.events = new Events();
|
this.events = new Events();
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
|
this.error = false;
|
||||||
this.builtContracts = {};
|
this.builtContracts = {};
|
||||||
this.compiledContracts = {};
|
this.compiledContracts = {};
|
||||||
|
|
||||||
|
@ -111,13 +112,19 @@ class Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
onReady(callback) {
|
onReady(callback) {
|
||||||
|
const self = this;
|
||||||
if (this.ready) {
|
if (this.ready) {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
if (this.error) {
|
||||||
|
return callback(this.error);
|
||||||
|
}
|
||||||
this.events.once('ready', () => {
|
this.events.once('ready', () => {
|
||||||
|
self.events.removeListener('deployError', () => {});
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
this.events.once('deployError', (err) => {
|
this.events.once('deployError', (err) => {
|
||||||
|
self.events.removeListener('ready', () => {});
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -180,9 +187,11 @@ class Test {
|
||||||
self._deploy(options, (err, accounts) => {
|
self._deploy(options, (err, accounts) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
self.events.emit('deployError', err);
|
self.events.emit('deployError', err);
|
||||||
|
self.error = err;
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
self.ready = true;
|
self.ready = true;
|
||||||
|
self.error = false;
|
||||||
self.events.emit('ready');
|
self.events.emit('ready');
|
||||||
next(null, accounts);
|
next(null, accounts);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue