Skip to content

Commit

Permalink
fix(fetch): remove terminated event listener on redirect (#1715)
Browse files Browse the repository at this point in the history
* fix(fetch): remove terminated event listener on redirect

* fix: use setMaxListeners instead

* Update lib/fetch/index.js

Co-authored-by: Robert Nagy <ronagy@icloud.com>
  • Loading branch information
KhafraDev and ronag authored Oct 26, 2022
1 parent 3d7de94 commit 9567c62
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class Fetch extends EE {
this.connection = null
this.dump = false
this.state = 'ongoing'
// 2 terminated listeners get added per request,
// but only 1 gets removed. If there are 20 redirects,
// 21 listeners will be added.
// See https://github.com/nodejs/undici/issues/1711
// TODO (fix): Find and fix root cause for leaked listener.
this.setMaxListeners(21)
}

terminate (reason) {
Expand Down

0 comments on commit 9567c62

Please sign in to comment.