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

Don't throw on timeout if RequestBuilder.noThrow is set #98

Open
andrewbrey opened this issue Jan 23, 2023 · 0 comments
Open

Don't throw on timeout if RequestBuilder.noThrow is set #98

andrewbrey opened this issue Jan 23, 2023 · 0 comments

Comments

@andrewbrey
Copy link
Contributor

andrewbrey commented Jan 23, 2023

In the following example:

import { $ } from "https://deno.land/x/[email protected]/mod.ts";

await $.request("https://example.com").noThrow().timeout(10).fetch();

unless example.com responds alarmingly fast, this code will throw an AbortError when the request is aborted thanks to the timeout(10).

This is the expected behavior of the abort controller, but in my opinion, is unexpected when the method you chain onto the RequestBuilder is called "noThrow".

In my opinion, either of the following would help things be more intuitive when noThrow is set and a timeout is triggered:

(a) rename noThrow to something else (ignoreHTTPStatus?) - this is a breaking change, but maybe with the module at v <1.0.0, that's ok?

(b) chain a catch onto the RequestBuilder.fetch method which simply returns undefined

This is just a suggestion, so as always feel free to close as won't fix if you feel that the API already makes sense for the majority of users, but wanted to surface the idea just in case!

Cheers, and thanks for considering :)

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

No branches or pull requests

1 participant