Skip to content

Body timeout not working #3297

@caldrjir

Description

@caldrjir

Bug Description

Our request below should fail on 'BodyTimeoutError', instead it seems to be an infinite timeout.

It happens mostly with bodyTimeout params higher than 500ms.

There is an example URL, in the code bellow, but it also happens with others.

Reproducible By

Run this code:

const fs = require('node:fs');
const { pipeline } = require('node:stream/promises');
const { request } = require('undici');

async function test() {
    const {body} = await request('http://79.8.16.194/cgi-bin/faststream.jpg?stream=full', {
        throwOnError: true,
        bodyTimeout: 1000,
    });
    await pipeline(body, fs.createWriteStream('./tmp/body-timeout-test'));
}

test();

Expected Behavior

Expecting BodyTimeoutError after 1000ms

BodyTimeoutError: Body Timeout Error
    at Timeout.onParserTimeout [as _onTimeout] (/YOUR_FOLDER_PATH/node_modules/undici/lib/dispatcher/client-h1.js:626:28)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  code: 'UND_ERR_BODY_TIMEOUT'
}

Environment

  • Node v21.2.0
  • NPM v10.5.1
  • macOS - Ventura 13.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions