-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
Open
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
Version
18.4
Platform
Darwin
Subsystem
No response
What steps will reproduce the bug?
I was trying to paginate results from a Stream using the .take operator but it's throwing an AbortError
import { Readable } from 'node:stream'
const data = Readable.from(['a', 'b', 'c', 'd'])
data.take(1).forEach(x => console.log(x));
data.take(2).forEach(x => console.log(x));
// AbortError: The operation was abortedor
import { Readable } from 'node:stream'
const data = Readable.from(['a', 'b', 'c'])
data.take(1).pipe(process.stdout)
data.take(2).pipe(process.stdout)
// AbortError: The operation was abortedHowever, using the code below keeps the stream working and prints the array without one char
import { Readable } from 'node:stream'
const data = Readable.from(['a', 'b', 'c', 'd'])
data.take(2).forEach(x => console.log(x, 'take 2'));
data.drop(1).take(1).forEach(x => console.log(x, 'drop 1 + take 1'));
/*
a take 2
d take 2
c drop 1 + take 1
*/or
import { Readable } from 'node:stream'
const data = Readable.from(['a', 'b', 'c'])
data.take(1).pipe(process.stdout)
data.drop(1).take(2).pipe(process.stdout)
//acHow often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
Consume chunks as specified
const data = Readable.from(['a', 'b', 'c'])
data.take(1).pipe(process.stdout)
data.take(2).pipe(process.stdout)
// abcWhat do you see instead?
// AbortError: The operation was aborted
Additional information
rluvaton
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.