Skip to content

Commit

Permalink
fix(Network): prevent same middleware from being added multiple times
Browse files Browse the repository at this point in the history
affects: @tao.js/core

added a guard to the use(middleware) function to check if the middleware is already in the
collection before adding it
  • Loading branch information
eudaimos committed Jun 27, 2020
1 parent 72fb205 commit d06913f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/tao/src/Network.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ export default class Network {
if (typeof middleware !== 'function') {
throw new Error('middleware must be a function');
}
this._middleware.add(middleware);
if (!this._middleware.has(middleware)) {
this._middleware.add(middleware);
}
}

stop(middleware) {
Expand Down

0 comments on commit d06913f

Please sign in to comment.