Skip to content

Commit

Permalink
fix(fetch): remove terminated event listener on redirect (nodejs#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
2 people authored and crysmags committed Feb 27, 2024
1 parent 40c1ff0 commit 6fb4ec8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/fetch/index.js
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 6fb4ec8

Please sign in to comment.