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

Retry network requests on ENOTFOUND #4459

Merged
merged 1 commit into from
Jun 14, 2019
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 packages/server/lib/request.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CookieJar = tough.CookieJar
## shallow clone the original
serializableProperties = Cookie.serializableProperties.slice(0)

NETWORK_ERRORS = "ECONNREFUSED ECONNRESET EPIPE EHOSTUNREACH EAI_AGAIN".split(" ")
NETWORK_ERRORS = "ECONNREFUSED ECONNRESET EPIPE EHOSTUNREACH EAI_AGAIN ENOTFOUND".split(" ")
VERBOSE_REQUEST_OPTS = "followRedirect jar strictSSL".split(" ")
HTTP_CLIENT_REQUEST_EVENTS = "abort connect continue information socket timeout upgrade".split(" ")

Expand Down
20 changes: 20 additions & 0 deletions packages/server/test/unit/request_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,26 @@ describe "lib/request", ->
expect(retries).to.eq(4)
done()

it "retries 4x on a NXDOMAIN (ENOTFOUND)", (done) ->
nock.enableNetConnect()

opts = {
url: "http://will-never-exist.invalid.example.com"
retryIntervals: [0, 1, 2, 3]
}

stream = request.create(opts)

retries = 0

stream.on "retry", ->
retries++

stream.on "error", (err) ->
expect(err.code).to.eq('ENOTFOUND')
expect(retries).to.eq(4)
done()

context "retries for promises", ->
it "does not retry on a timeout", ->
opts = {
Expand Down