dsherret / dsherret/dax

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

Open
#98 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.5k
Forks
42
Avg merge
11m
Merged PRs (30d)
2

Description

In the following example:

```ts
import { $ } from "https://deno.land/x/dax@0.24.1/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 :)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the TypeScript implementation of RequestBuilder.noThrow(), timeout(), and fetch(), then inspect any existing request or timeout tests. Clarify whether noThrow should suppress timeout AbortErrors or only HTTP-status errors, and document the chosen behavior in a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
deno, typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.