question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`streamx.pipe()` does not add a listener for `data` event.

See original GitHub issue

streamx.pipe(dest) does not attach a data listener to streamx as stream v3 does. My goal is to migrate to-through from though2 to streamx.Transform, to do this I need to be able to know when streamx is piped to or from.

Stream code sometimes watches for the newListener event with data or readable for the argument.

Examples: https://github.com/mcollina/cloneable-readable/blob/f6bbe0a9da6561af84ec14ca1bc75c37c455f11c/index.js#L23-L38 https://github.com/gulpjs/to-through/blob/552d17efd3f9469166bc87832e77e86602850828/index.js#L34-L43

I’m not sure if it would be appropriate for ReadableState#pipe to call this.stream.emit('newListener', 'data') directly.

Related to #14

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14

github_iconTop GitHub Comments

2reactions
mafintoshcommented, May 26, 2020

I’m one of the maintainers of those.

The idea with streamx isn’t to be 100% compat, but to break compat if it means we can massively simplify/perf boost. That’s why pipe is different along with other tweaks.

We can probably add more explicit events to Node.js streams though. I’ll make an issue for that on Node.

1reaction
coreyfarrellcommented, Oct 22, 2020

@mafintosh thanks for adding the new events. Sorry I haven’t been about to give feedback / testing yet, life has pulled me in other directions for now.

@phated TBH it’s going to early next year before I’m able to put any serious effort into any open source code. In addition to current work commitments I am in the process of a long distance move. I have not forgotten about gulp and plan to work towards getting things migrated to streamx but I want to give reasonable expectation based on my schedule.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - No data after piping response stream - Stack Overflow
Answering my own question, but the issue is reading from multiple sources: the resolved promise and the 'data' event. The event listener ......
Read more >
Events and Streams in Node.js - codeburst
console.log(eventName, 'listener added', listenerFunction.name); ... However, we can consume streams data in a simpler way using the pipe method.
Read more >
Stream | Node.js v19.3.0 Documentation
If an encoding is not set, Buffer objects will be received. req.setEncoding('utf8'); // Readable streams emit 'data' events once a listener is added....
Read more >
Getting Started with Node Streams - CODE Magazine
An EventEmitter allows consuming code to add listeners for events ... Pipe offers a better alternative for reading data from a stream and ......
Read more >
Streams, Piping, and Their Error Handling in Node.js - Medium
For example, creating a write stream to write a text file for some ... Instead of listening to the data and the end...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found