Skip to content

Add option to automatically abort response stream if the data stopped arriving for longer than a specified time #180

@kornelski

Description

@kornelski

I'd like to have an option to abort (internally by the browser, not via a JS API) requests that have stalled, i.e. close the TCP/IP connection if the time since the last bit data received exceeded a specified timeout.

This is different from a deadline (#179, #20), because it allows very slow, but steady, responses to stream forever.

fetch('/1MB.json', {timeout: 5000}).then(res => res.json);

This promise would succeed on a GPRS connection with a good signal that requires 4 minutes to download the file, but thanks to a good signal it delivers the file at a good consistent pace, so there's never a gap longer than 5 seconds between received chunks of the file.

This promise would fail on a fast 4G connection in 5 seconds after the user has lost signal, even if a portion of the file has already been downloaded, but due to lost signal the rest of the file stopped arriving.

Timeout-since-last-data-arrived is a timeout independent of file size and mostly indifferent to the network speed. This allows developers to use shorter timeouts than if they had to use a worst-case-scenario deadline for the whole response to arrive, so the application can react to failing network conditions quicker, and minimize time spent in a "stuck" state.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions