Repository navigation
stream: using an async iterator on a pipeline works on v18 but in v19 needs Readable.from(asyncItFn) #46141
Description
Activity
- addedstreamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
on Jan 9, 2023 Adding
import 'node:stream'at the top fixes it :/@mcollina the problem here is all the global stream init logic lives in 'stream', so at the moment you must first import 'stream' before anything else under 'stream/...'
- addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Jan 9, 2023 OMG 😂
I'd like to help working on it. Do you know where to look at?
Reacted by Robert Nagynode/lib/stream.js
node/lib/stream/promises.jsReacted by Erick Wendel and Fabien Foerster@mcollina the problem here is all the global stream init logic lives in 'stream', so at the moment you must first import 'stream' before anything else under 'stream/...'
do other bugs are happening because of it?
Analyzing here it works without going on 'node:stream/promises':
import { promises } from 'node:stream' const { pipeline } = promises async function* myCustomReadable() { yield Buffer.from(`tick: ${new Date().toISOString()}`) } async function* myCustomWritable(stream) { for await (const chunk of stream) { console.log(chunk.toString()) } } await pipeline( myCustomReadable, myCustomWritable, )
But looking at the code, here is the problem:
if I change from
require('internal/streams/passthrough')torequire('stream').Passthroughit works. it seems to be something on the loader sideGonna take a look at it tonight
Reacted by Emerson Silva- added a commit that references this issue
on Jan 9, 2023 - changed the title
[-]stream: using a async iterator on a pipeline works on v18 but in v19 needs Readable.from(asyncItFn)[/-][+]stream: using an async iterator on a pipeline works on v18 but in v19 needs Readable.from(asyncItFn)[/+]on Jan 9, 2023 - added a commit that references this issue
on Jan 20, 2023 - added a commit that references this issue
on Feb 1, 2023 - added 2 commits that reference this issue
on Mar 3, 2023
Version
19.3
Platform
darwin
Subsystem
No response
What steps will reproduce the bug?
The code below works on
v18.13.0but crashes onv19.3.0but it works if explicitly convert it to a Readable
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
TypeError: Right-hand side of 'instanceof' is not an objectAdditional information
@nodejs/streams @nodejs/tooling