-
-
Notifications
You must be signed in to change notification settings - Fork 957
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
Conversation
I'll leave this part: Lines 30 to 32 in 6ba9e68
this makes us sure |
We also need tests for |
I just wonder if this piece of code is needed: Lines 31 to 33 in 6ba9e68
because I tried passing a |
if (is.number(after)) { | ||
after *= 1000; | ||
if (is.nan(after)) { | ||
after = Date.parse(error.headers['retry-after']) - Date.now(); |
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 return true
for NaN, but I was wrong.
Math.max
is not needed BTW.
} catch (error2) { | ||
emitter.emit('error', error2); | ||
} | ||
}, backoff, options); |
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.
Why was this removed?
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.
get()
does not throw any errors directly. It uses emitter.emit('error', error);
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.
Good point. I think we need a try/catch here though: https://github.com/sindresorhus/got/pull/542/files#diff-62bdc57f6f22ae58f495daef16f21f8bR141 In case the options.gotRetry.retries
function throws.
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.
I see I've added it here. It's no longer needed because decodeURI
error is catched here. If it wasn't there then we would need to catch on setTimeout
too. But there's no need as metioned :)
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 comment
The 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 comment
The 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: const backoff = options.gotRetry.retries(++retryTries, error);
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.
you're not answering my question.
Sorry, if you're talking about the second one then it hadn't popped up when I was writing the answer. Pardon my confusion.
I think we need to try/catch this line because it could throw
Good point! Indeed. 🙌
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.
I think we need to try/catch this line because it could throw
Good point! Indeed. 🙌
And of course a test ;)
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.
Done! I hope it satisfies you :)
You have to pass a stream. The buffer testing is testing a property on the stream. |
@sindresorhus But it's converted to a stream here: got/source/normalize-arguments.js Lines 111 to 114 in 6ba9e68
|
@szmarczak Hmm, then maybe it returns here: Line 10 in 6ba9e68
debugger statement to each if and figure out where it returns.
|
Yeah, you're right, checked it. So, is it needed? IMO we can get rid of that. |
See: got/source/request-as-event-emitter.js Lines 163 to 166 in 4d92eb6
This should be done in a separate PR though |
test/retry.js
Outdated
throw new Error('Simple error'); | ||
} | ||
} | ||
}), 'Simple error'); |
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.
It's a good practice to put the message in a variable and use it in both to make absolutely sure they are the same and stay the same in the future too.
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.
Yeah.
So it will be :)
Done 🦄 |
Nah, don't care. If it prevents us from getting 100% test coverage, we can just mock it.
Do you intend to do that in this PR? Asking so I know whether this is ready to merge or not. |
Something is failing here: https://ci.appveyor.com/project/sindresorhus/got/build/1.0.245/job/nunr63w0rttwjv0t |
The point is: not only that keeps us from 100%. But it's possible to achieve 99% :)
No, that'll be a separate PR too. Yes, it's ready to merge now :) |
AppVeyor is damn slow. Increasing the timeouts should fix the problem I think. If it does not, I'll fix it in the morning as it's 10:21 PM here. |
See? Fixed :) |
Yup, AppVeyor is annoying. We had so many problems with it over at https://github.com/avajs/ava too... |
👍 I'm extra happy that doing this actually caught a couple of potential bugs. |
No description provided.