Skip to content

Socks5ProxyAgent ignores options.connect #5167

@trivikr

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

Metadata

Metadata

Assignees

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