MaxListenersExceededWarning when using signal (original) (raw)

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