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: dns interceptor error handling #3729

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
43 changes: 13 additions & 30 deletions lib/interceptor/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,37 +220,20 @@ class DNSDispatchHandler extends DecoratorHandler {
}

onError (err) {
switch (err.code) {
case 'ETIMEDOUT':
case 'ECONNREFUSED': {
if (this.#state.dualStack) {
// We delete the record and retry
this.#state.runLookup(this.#origin, this.#opts, (err, newOrigin) => {
if (err) {
return this.#handler.onError(err)
}

const dispatchOpts = {
...this.#opts,
origin: newOrigin
}

this.#dispatch(dispatchOpts, this)
})

// if dual-stack disabled, we error out
return
}
this.#state.deleteRecord(this.#origin)

this.#handler.onError(err)
return
}
case 'ENOTFOUND':
this.#state.deleteRecord(this.#origin)
// eslint-disable-next-line no-fallthrough
default:
this.#handler.onError(err)
break
if (this.#state.dualStack && (err.code === 'ETIMEDOUT' || err.code === 'ECONNREFUSED')) {
// We delete the record and retry
this.#state.runLookup(this.#origin, this.#opts, (err, newOrigin) => {
if (err) {
this.#handler.onError(err)
} else {
// TODO (fix): How to avoid infinite loop?
this.#dispatch({ ...this.#opts, origin: newOrigin }, this)
ronag marked this conversation as resolved.
Show resolved Hide resolved
}
})
} else {
this.#handler.onError(err)
}
}
}
Expand Down
Loading