nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.45k stars 278 forks source link

src.once is not a function in pipeline #4221

Closed kevin-ye225 closed 2 months ago

kevin-ye225 commented 1 year ago

Details

Hi, I am currently doing pipeline(res.body, dest, err => err handling) after getting the response from node-fetch, after upgrading to node 18, it is throwing an error saying that src.once is not a function, I look at the response type from node-fetch, while the body is indeed a ReadableStream that implements EventEmitter, which has a once function, when I log it, it says undefined, which is why it is causing this to fail i think.

I tried switching to the global fetch provided in node 18 with no luck. How should I address this? polyfill the once function somehow?

Node.js version

18.17.0

Example code

pipeline(res.body, dest, (err) => { if (err) { return rej(err); } return res(); });

Operating system

macOS

Scope

runtime

Module and version

Not applicable.

prettydiff commented 1 year ago

Please provide a sample of code so that any of us can experiment and attempt to reproduce your concerns.

You did provide a sample. Sorry, I missed it (my fault). Next time though try wrapping the code sample in back ticks so that the markdown formats it as code explicitly, for example

```
some code
```

Is pipeline sourced from the stream library as in : import {pipeline} from "node:stream"? Also I do not see a src object in the code sample, so where does that come into play. The once method is available upon events and event emitters, so you should expect src.once to be undefined if src is not an event or event emitter:

https://nodejs.org/api/events.html

github-actions[bot] commented 3 months ago

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] commented 2 months ago

It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.