Skip to content

Use of HTTP_PROXY & NODE_USE_ENV_PROXY fails with an infinite loop #5093

@ArnaudBuchholz

Description

@ArnaudBuchholz

Bug Description

I have been experimenting with HTTP_PROXY & NODE_USE_ENV_PROXY and realized that the created ProxyAgent uses proxyTunnel: true by default which may fail if the proxy does not implement CONNECT. As a result, undici loops forever.

Reproducible By

See https://github.com/ArnaudBuchholz/training-fetch-proxy
run the proxy using node reserve-proxy
use npm run native-fetch to reproduce the issue.
use NODE_DEBU=undici npm run native-fetch to see the infinite loop

Expected Behavior

Have a way to disable proxyTunnel

Logs & Screenshots

UNDICI 13766: connecting to www.google.com using http:undefined
UNDICI 13766: connecting to localhost:8989:8989 using http:undefined
UNDICI 13766: connected to localhost:8989:8989 using http:h1
UNDICI 13766: sending request to CONNECT http://localhost:8989www.google.com:80
UNDICI 13766: request to CONNECT http://localhost:8989www.google.com:80 errored - other side closed
UNDICI 13766: connection to www.google.com using http:undefined errored - other side closed
UNDICI 13766: connecting to www.google.com using http:undefined
UNDICI 13766: connecting to localhost:8989:8989 using http:undefined
UNDICI 13766: connected to localhost:8989:8989 using http:h1
UNDICI 13766: sending request to CONNECT http://localhost:8989www.google.com:80
UNDICI 13766: request to CONNECT http://localhost:8989www.google.com:80 errored - other side closed
UNDICI 13766: connection to www.google.com using http:undefined errored - other side closed
UNDICI 13766: connecting to www.google.com using http:undefined
UNDICI 13766: connecting to localhost:8989:8989 using http:undefined
UNDICI 13766: connected to localhost:8989:8989 using http:h1
UNDICI 13766: sending request to CONNECT http://localhost:8989www.google.com:80
UNDICI 13766: request to CONNECT http://localhost:8989www.google.com:80 errored - other side closed
UNDICI 13766: connection to www.google.com using http:undefined errored - other side closed
UNDICI 13766: connecting to www.google.com using http:undefined
UNDICI 13766: connecting to localhost:8989:8989 using http:undefined
UNDICI 13766: connected to localhost:8989:8989 using http:h1

Environment

Mac OS / Tahoe 26.3.1
Node 24.14

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