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 redirect timeout #685

Closed
wants to merge 2 commits into from
Closed

Conversation

gdoron
Copy link

@gdoron gdoron commented Oct 10, 2019

Current implementation resets the timeout on every redirect.
It can cause severe issues when the user is willing to wait only for x amount of seconds.
But because the remote server redirects him, he can wait a lot more (maybe even indefinitely)

@bitinn makes sense?

@codecov-io
Copy link

codecov-io commented Oct 10, 2019

Codecov Report

Merging #685 into master will decrease coverage by 0.68%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #685      +/-   ##
==========================================
- Coverage     100%   99.31%   -0.69%     
==========================================
  Files           7        7              
  Lines         579      586       +7     
  Branches      185      187       +2     
==========================================
+ Hits          579      582       +3     
- Misses          0        3       +3     
- Partials        0        1       +1
Impacted Files Coverage Δ
src/index.js 96.66% <50%> (-3.34%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e99050...40a280a. Read the comment docs.

@Richienb
Copy link
Member

Please unit test this.

@Richienb Richienb requested a review from bitinn October 10, 2019 21:22
@Richienb Richienb assigned xxczaki and unassigned xxczaki Oct 10, 2019
@gdoron
Copy link
Author

gdoron commented Oct 10, 2019

@Richienb I'm quite new to codecov so sorry for the noob question.
Is there a way of knowing which lines are not covered because of this new pull request?

@Richienb
Copy link
Member

@gdoron
Copy link
Author

gdoron commented Oct 10, 2019

@Richienb I can't seem to find a way to make the test spend on the first request in the chain exactly the time given in the timeout property.
I can remove lines 162-166 and then there won't be any test-coverage issue, but that's wrong.
Any suggestions?

@Richienb
Copy link
Member

@gdoron Since we can't match the exact time specified as the timeout, we should not be exact.

@gdoron
Copy link
Author

gdoron commented Oct 10, 2019

@Richienb I can remove these lines, and all will keep working.
These lines just save sending another request if the timeout just expired.
Since we already know the next request won't make in 0 ms.

Do you want me to remove this edge-case?

@Richienb
Copy link
Member

I'll let another reviewer chime in here.

@gdoron
Copy link
Author

gdoron commented Oct 10, 2019

Actually removing handling this edge case will cause removing the timeout completely from the next request in case the remaining time is 0, since 0 is a "falsy value".

@bitinn
Copy link
Collaborator

bitinn commented Oct 11, 2019

Thx for the PR, but as explain in #615, timeout was an extension to Fetch spec, we are not planning to change this behavior as many are depending on this behavior. And we plan to drop timeout eventually. Use AbortSignal instead.

#615 (comment)

@xxczaki
Copy link
Member

xxczaki commented Oct 11, 2019

@bitinn Are we going to drop timeout support in 3.x or not yet? We can always add a warning message when user is using timeout to let them know, that it will be deprecated soon.

@Richienb
Copy link
Member

@xxczaki Timeout already has a deprecation path in the 3.x roadmap and is outlined in #523.

@xxczaki
Copy link
Member

xxczaki commented Oct 12, 2019

@Richienb Ok, as it was striked out in the roadmap, I'm going to add it again 😄

@gdoron
Copy link
Author

gdoron commented Oct 12, 2019

Thanks for the answer.
I just find it very hard to believe anyone using the library understood the timeout behaves as it does now.
Actually it took me significant amount of time understanding what's happening in my application, how the average time I see in DataDog exceeds significantly the timeout value I used.

And anyway, if someone wants the current implementation, Abort Signal won't allow him maintain his current flow once you drop support of timeout.

I would reconsider, but it's up to you.
Thanks for your time!
@bitinn

@gdoron
Copy link
Author

gdoron commented Oct 19, 2019

@bitinn did you see my last comment?
Do you want me to close the PR?

Copy link
Member

@Richienb Richienb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bitinn @xxczaki Since we're going to deprecate timeout in favour of AbortController in v3, we can probably include these changes in the final update for v2.

@bitinn
Copy link
Collaborator

bitinn commented Oct 20, 2019

@gdoron Sorry, I will have to close this PR, the timeout + follow redirect scenario is setup for web crawler type use cases: You want to follow redirect, but just can't be sure how long each redirect would take. If you want to limit the timeout in v2, use timeout + don't follow redirect or timeout + limit total redirect to N (so maximum timeout is timeout x N), or use AbortController which is the spec compliant way.

@bitinn bitinn closed this Oct 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants