Skip to content

Socks5ProxyAgent.dispatch() returns a Promise instead of boolean #5165

@trivikr

Description

@trivikr

Bug Description

Socks5ProxyAgent.dispatch() returns a Promise instead of boolean

Socks5ProxyAgent[kDispatch] is declared async, so the public Socks5ProxyAgent.dispatch() method returns a Promise instead of the documented boolean backpressure signal.

Dispatcher.dispatch() is documented to return Boolean, where false means the dispatcher is busy until a 'drain' event is emitted. Socks5ProxyAgent.dispatch() currently cannot provide that synchronous signal because async [kDispatch] wraps the underlying pool[kDispatch](opts, handler) return value in a Promise.

Reproducible By

import { Socks5ProxyAgent } from 'undici'

const agent = new Socks5ProxyAgent('socks5://127.0.0.1:1080')

const ret = agent.dispatch({
  origin: 'http://example.com',
  path: '/',
  method: 'GET'
}, {
  onConnect () {},
  onHeaders () {},
  onData () {},
  onComplete () {},
  onError () {}
})

console.log(ret)
console.log(typeof ret.then)

Expected Behavior

Socks5ProxyAgent.dispatch() should return the synchronous boolean returned by the underlying dispatcher

Logs & Screenshots

Promise { <pending> }
function

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