unjs / unjs/ofetch

`timeout` option doesn't timeout body parsing

Open
#620 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.4k
Forks
195
PR merge metrics
No merged PRs in 30d

Description

Environment

ofetch: 1.5.1
Node.js: v22.21.1

Reproduction

https://github.com/dword-design/demo-ofetch-response-body-timeout

node index.js
Describe the bug

Looks like the timeout option only covers the request phase, but when a response is incomplete, the body parsing hangs.

Expected
When the response is incomplete, the request is aborted with a timeout error.

Actual
The request doesn't return.

Additional context

It works with { signal: AbortSignal.timeout(<timeout>) }. Probably because this is passed to the underlying fetch call.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction and run node index.js to observe the incomplete response body. Trace how the timeout option and AbortSignal.timeout(<timeout>) reach the underlying fetch call; done means an incomplete response is aborted and returns a timeout error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.