Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass family parameter to connect method #21545

Merged
merged 2 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/network/lib/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ export function getDelayForRetry (iteration) {
}

interface RetryingOptions {
family: 4 | 6 | 0
port: number
host: string | undefined
useTls: boolean
getDelayMsForRetry: (iteration: number, err: Error) => number | undefined
}

function createSocket (opts: RetryingOptions, onConnect): net.Socket {
const netOpts = _.pick(opts, 'host', 'port')
const netOpts = _.defaults(_.pick(opts, 'family', 'host', 'port'), {
family: 4,
})

if (opts.useTls) {
return tls.connect(netOpts, onConnect)
Expand Down
4 changes: 2 additions & 2 deletions packages/network/test/unit/agent_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ describe('lib/agent', function () {
const proxy = url.parse('http://foo.bar:1234')

createProxySock({ proxy }, () => {
expect(net.connect).to.be.calledWith({ host: 'foo.bar', port: 1234 })
expect(net.connect).to.be.calledWith({ family: 4, host: 'foo.bar', port: 1234 })
done()
})
})
Expand All @@ -630,7 +630,7 @@ describe('lib/agent', function () {
const proxy = url.parse('https://foo.bar:1234')

createProxySock({ proxy }, () => {
expect(tls.connect).to.be.calledWith({ host: 'foo.bar', port: 1234 })
expect(tls.connect).to.be.calledWith({ family: 4, host: 'foo.bar', port: 1234 })
done()
})
})
Expand Down