Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix aborting Streams #3754

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/web/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,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 Expand Up @@ -1943,7 +1949,6 @@ async function httpNetworkFetch (
// 19. Run these steps in parallel:

// 1. Run these steps, but abort when fetchParams is canceled:
fetchParams.controller.onAborted = onAborted
fetchParams.controller.on('terminated', onAborted)
fetchParams.controller.resume = async () => {
// 1. While true
Expand Down Expand Up @@ -2205,10 +2210,6 @@ async function httpNetworkFetch (
fetchParams.controller.off('terminated', this.abort)
}

if (fetchParams.controller.onAborted) {
fetchParams.controller.off('terminated', fetchParams.controller.onAborted)
}

fetchParams.controller.ended = true

this.body.push(null)
Expand Down
33 changes: 0 additions & 33 deletions test/fetch/issue-1711.js

This file was deleted.