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

feat: support 'requestTimeout' option #136

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

FredZeng
Copy link
Contributor

No description provided.

@xqq
Copy link
Owner

xqq commented Sep 23, 2023

You'd better use a more general name, like requestTimeout or networkTimeout, since we are using fetch + ReadableStream on most platforms rather than XHR-based for now.

BTW, what time is your timeout pointing to?
The elapsed time from the request sent until the response header is received?
Or the elapsed time of downloading the full file?

@FredZeng
Copy link
Contributor Author

FredZeng commented Sep 24, 2023

I have renamed the xhrTimeout option to requestTimeout, it stands for The elapsed time from the request sent until the response header is received.

Why we need such option?
Because browsers like Chrome require around 20 seconds to throw a timeout error when accessing an unreachable address(e.g. accessing a private network address in public), sometimes we prefer to a faster response.

@xqq
Copy link
Owner

xqq commented Sep 24, 2023

Have you confirmed that a slow download (where the response header is received) won't cause a timeout in XHR?

@FredZeng FredZeng marked this pull request as draft September 25, 2023 04:05
@FredZeng FredZeng marked this pull request as ready for review September 25, 2023 04:32
@FredZeng
Copy link
Contributor Author

Thanks for pointing out my mistake. According to the XHR Standard https://xhr.spec.whatwg.org/#the-timeout-attribute, even if a response header is received, a timeout error will be dispatched as long as the request has not been completed, and I have already tested such situation.
So I implemented requestTimeout option using setTimeout instead.

@FredZeng FredZeng changed the title feat: support 'xhrTimeout' option feat: support 'requestTimeout' option Mar 29, 2024
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.

2 participants