Retry network requests on ENOTFOUND (#4459)

This commit is contained in:
Zach Bloomquist
2019-06-13 23:25:57 -04:00
committed by Brian Mann
parent 387ca00068
commit c4a0fddd5f
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -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(" ")
@@ -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 = {