grantila / grantila/fetch-h2

timeout option has no effect if set on Request

Open
#84 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
336
Forks
15
PR merge metrics
No merged PRs in 30d

Description

I assume the following 2 `fetch` invocations should behave identically, i.e. both should throw a `TimeoutError`:

A: Passing url and options directly to `fetch()`:
```javascript
const resp = await fetch('https://httpbin.org/delay/5', { timeout: 1000 });
```

B: Passing url and options via `Request` instance to `fetch()`:
```javascript
const req = new Request('https://httpbin.org/delay/5', { timeout: 1000 });
const resp = await fetch(req);
```

A throws a `TimeoutError` as expected. B OTOH ignores the `timeout` option and succeeds.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the two fetch examples in the issue, comparing direct options with a Request instance. Trace how fetch reads timeout from each entry point; done means both forms reject with a TimeoutError when the delayed URL exceeds the timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.