Remove all input event listeners on a node once it is closed

This prevents in-flight messages being passed to the node after
it has closed.
This commit is contained in:
Nick O'Leary 2021-05-13 13:37:21 +01:00
parent c47b553a8e
commit 001f066769
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 3 additions and 1 deletions

View File

@ -338,12 +338,14 @@ Node.prototype.close = function(removed) {
}
}
if (promises.length > 0) {
return Promise.all(promises).then(function() {
return Promise.all(promises).then(() => {
this.removeAllListeners("input")
if (this._context) {
return context.delete(this._alias||this.id,this.z);
}
});
} else {
this.removeAllListeners("input")
if (this._context) {
return context.delete(this._alias||this.id,this.z);
}