Skip to content

MaxListenersExceededWarning when using signal #5285

@axetroy

Description

@axetroy

Bug Description

When a signal is passed to fecth, an abort event is listened for.

However, when requesting a result, there is no overflow listener for the abort event. This means that if the same signal is used for multiple requests, there is a risk of signal leakage, and Node.js continuously outputs warnings.

(node:14604) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 9053 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit

Reproducible By

        const response = await fetch(requestUrl, {
            method,
            headers: requestHeaders,
            dispatcher: downloadAgent,
            signal
        })

Expected Behavior

The abort event listener should be canceled when the request ends.

Logs & Screenshots

Environment

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions