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(3951): typo on errorede dns lookup #3956

Merged
merged 2 commits into from
Dec 18, 2024
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
2 changes: 1 addition & 1 deletion lib/interceptor/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ module.exports = interceptorOpts => {

instance.runLookup(origin, origDispatchOpts, (err, newOrigin) => {
if (err) {
return handler.onError(err)
return handler.onResponseError(null, err)
}

let dispatchOpts = null
Expand Down
25 changes: 25 additions & 0 deletions test/interceptors/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -1814,3 +1814,28 @@ test('#3937 - Handle host correctly', async t => {
t.equal(response2.statusCode, 200)
t.equal(await response2.body.text(), 'hello world!')
})

test('#3951 - Should handle lookup errors correctly', async t => {
const suite = tspl(t, { plan: 1 })

const requestOptions = {
method: 'GET',
path: '/',
headers: {
'content-type': 'application/json'
}
}

const client = new Agent().compose([
dns({
lookup: (_origin, _opts, cb) => {
cb(new Error('lookup error'))
}
})
])

suite.rejects(client.request({
...requestOptions,
origin: 'http://localhost'
}), new Error('lookup error'))
})
Loading