-
-
Notifications
You must be signed in to change notification settings - Fork 956
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
Increase coverage #542
Increase coverage #542
Changes from 7 commits
c415146
7148bef
94fac09
c77c011
ec09eef
ed7489e
a86e47e
93f4408
59b6f16
3609221
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ const {GotError, CacheError, UnsupportedProtocolError, MaxRedirectsError, Reques | |
const getMethodRedirectCodes = new Set([300, 301, 302, 303, 304, 305, 307, 308]); | ||
const allMethodRedirectCodes = new Set([300, 303, 307, 308]); | ||
|
||
module.exports = (options = {}) => { | ||
module.exports = options => { | ||
const emitter = new EventEmitter(); | ||
const requestUrl = options.href || (new URLGlobal(options.path, urlLib.format(options))).toString(); | ||
const redirects = []; | ||
|
@@ -142,13 +142,7 @@ module.exports = (options = {}) => { | |
|
||
if (backoff) { | ||
retryCount++; | ||
setTimeout(options => { | ||
try { | ||
get(options); | ||
} catch (error2) { | ||
emitter.emit('error', error2); | ||
} | ||
}, backoff, options); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I think we need a try/catch here though: https://github.com/sindresorhus/got/pull/542/files#diff-62bdc57f6f22ae58f495daef16f21f8bR141 In case the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see I've added it here. It's no longer needed because I'll deny my answer: It was caught nowhere. I don't know how I did get that 😕 To sum up: the removal is good, I'm sure 10000% :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope my answer is no confusing :P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your answer is not confusing, but you're not answering my question. To be clear, I think we need to try/catch this line because it could throw: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, if you're talking about the second one then it hadn't popped up when I was writing the answer. Pardon my confusion.
Good point! Indeed. 🙌 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
And of course a test ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! I hope it satisfies you :) |
||
setTimeout(get, backoff, options); | ||
cb(true); | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a bug: at first I thought
is.number
won't returntrue
for NaN, but I was wrong.Math.max
is not needed BTW.