You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>> ERROR: stream.pipe is not a function (NodeID: felipe-xps-15-9550-24145)
TypeError: stream.pipe is not a function
at Service.get (/home/felipe/Documents/Workspace/moleculer/azure-stream-moleculer-issue/assets.service.js:11:14)
at <anonymous>
Unless you have reasons to do not use it, we should just check with instanceof.
if (data && data instanceof Stream)
or if you want to make sure it's a Readable stream we could also use data.readable === true. Duplex streams not always seems to have the read function but it still working as Readable stream.
This implementation for example inherits from Stream and implements its own Duplex. Although it's Readable and Writable, it would fail for Readable, Writable, Duplex and Transform instanceof checks.
Share your thoughts,
Tks
The text was updated successfully, but these errors were encountered:
Yes. I've checked this thread as well. There are some ways to try to determine if it's actually a Readable stream. Take a look at this project here. They use stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object';. But it also return false when checking the azure ChunkStream as readable. I'm not saying the azure ChunkStream is correct but it works as a Readable stream as well.
Expected Behavior
It should return a Duplex stream from a remote node.
Failure Information
You can find details on how to duplicate the issue in the repo https://github.com/felipegcampos/azure-stream-moleculer-issue
Context
Failure Logs
Solution
Issue is here:
if (data && typeof data.on === "function" && typeof data.read === "function" && typeof data.pipe === "function") {
Unless you have reasons to do not use it, we should just check with instanceof.
if (data && data instanceof Stream)
or if you want to make sure it's a Readable stream we could also use
data.readable === true
. Duplex streams not always seems to have theread
function but it still working as Readable stream.or even:
if (data && typeof data.on === "function" && typeof data.pipe === "function" && data.readable === true)
This implementation for example inherits from Stream and implements its own Duplex. Although it's Readable and Writable, it would fail for Readable, Writable, Duplex and Transform
instanceof
checks.Share your thoughts,
Tks
The text was updated successfully, but these errors were encountered: