Skip to content

Socks5ProxyAgent ignores options.connect #5167

Description

@trivikr

Bug Description

Socks5ProxyAgent ignores options.connect

Reproducible By

import net from 'node:net'
import { request, Socks5ProxyAgent } from 'undici'

let called = false

const agent = new Socks5ProxyAgent('socks5://127.0.0.1:1080', {
  connect (_, cb) {
    called = true
    cb(new Error('custom connector used'))
  }
})

await request('http://example.com', { dispatcher: agent }).catch(() => {})
await agent.close().catch(() => {})

console.log({ called })

Expected Behavior

options.connect should be called to create the connection to the SOCKS5 proxy.

Logs & Screenshots

options.connect is not called. createSocks5Connection() calls net.connect() directly.

{ called: false }

Environment

macOS 26.4.1
Node v24.15.0
undici v8.2.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions