Streams

Readable.isDisturbed()

Reports whether a Node readable or Web readable has been consumed or canceled. Useful for guarding a single-consumer contract; it does not report how many bytes remain. The Node 22.16.0 documentation marks this interface experimental. Tested on Node.js 22.16.0. Example output (one line per entry): ["false", "book", "true"].

Formal Syntax & Structure

nodejs syntaxnodejs
Readable.isDisturbed(stream)

Parameters & Attributes

NameTypeDescription
streamReadable | ReadableStreamStream to inspect.

Return Value

boolean

Whether read or cancellation has occurred.

Working Example

Example Snippetnodejs
import { Readable } from 'node:stream';const source = Readable.from(['book']);console.log(Readable.isDisturbed(source));for await (const chunk of source)    console.log(chunk);console.log(Readable.isDisturbed(source));
Node.js Reference