Skip to content

Commit

Permalink
WebsocketProvider, AbstractSocketProvider, and AbstractSubscription e…
Browse files Browse the repository at this point in the history
…vent handling updated
  • Loading branch information
Samuel Furter committed May 31, 2019
1 parent 1dd6536 commit 39f0be2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export default class AbstractSubscription extends EventEmitter {
*
* @param {AbstractWeb3Module} moduleInstance
*/
beforeSubscription(moduleInstance) {
}
beforeSubscription(moduleInstance) { }

/**
* This method will be executed on each new subscription item.
Expand Down Expand Up @@ -164,7 +163,7 @@ export default class AbstractSubscription extends EventEmitter {
.then((response) => {
if (!response) {
const error = new Error('Error on unsubscribe!');
if (isFunction(callback)) {
if (callback) {
callback(error, null);
}

Expand All @@ -177,7 +176,7 @@ export default class AbstractSubscription extends EventEmitter {
this.id = null;
this.removeAllListeners();

if (isFunction(callback)) {
if (callback) {
callback(false, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ export default class AbstractSocketProvider extends EventEmitter {
onError(error) {
this.emit(this.ERROR, error);
this.emit(this.SOCKET_ERROR, error);
this.removeAllSocketListeners();
this.removeAllListeners();
}

/**
Expand Down
8 changes: 0 additions & 8 deletions packages/web3-providers/src/providers/WebsocketProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,6 @@ export default class WebsocketProvider extends AbstractSocketProvider {
.then(resolve)
.catch(reject);
});
}).then((response) => {
this.removeListener('error', reject);

This comment has been minimized.

Copy link
@boomfly

boomfly May 31, 2019

without removing listeners on lost connection node exception probable EventEmitter memory leak


return response;
}).catch((error) => {
this.removeListener('error', reject);

This comment has been minimized.

Copy link
@boomfly

boomfly May 31, 2019

this needs too


throw error;
});
}
}

0 comments on commit 39f0be2

Please sign in to comment.