nodejs / readable-stream

Node-core streams for userland
https://nodejs.org/api/stream.html
Other
1.03k stars 227 forks source link

TypeError undefined for chunk #305

Closed RWOverdijk closed 7 years ago

RWOverdijk commented 7 years ago

I'm getting the following error:

/private/tmp/aurelia-orm/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:257
      if (typeof chunk !== 'string' && Object.getPrototypeOf(chunk) !== Buffer.prototype && !state.objectMode) {
                                              ^

TypeError: Cannot convert undefined or null to object
    at Function.getPrototypeOf (<anonymous>)
    at readableAddChunk (/private/tmp/aurelia-orm/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:257:47)
    at DestroyableTransform.Readable.push (/private/tmp/aurelia-orm/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:237:10)
    at DestroyableTransform.Transform.push (/private/tmp/aurelia-orm/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:146:32)
    at /private/tmp/aurelia-orm/node_modules/aurelia-tools/src/build.js:43:12
    at action (/private/tmp/aurelia-orm/node_modules/breeze-dag/lib/dag.js:93:5)
    at Queue.process (/private/tmp/aurelia-orm/node_modules/breeze-queue/lib/queue.js:174:5)
    at next (/private/tmp/aurelia-orm/node_modules/breeze-queue/lib/queue.js:182:12)
    at done (/private/tmp/aurelia-orm/node_modules/breeze-dag/lib/dag.js:102:7)
    at /private/tmp/aurelia-orm/node_modules/aurelia-tools/src/build.js:44:7
    at action (/private/tmp/aurelia-orm/node_modules/breeze-dag/lib/dag.js:93:5)
    at Queue.process (/private/tmp/aurelia-orm/node_modules/breeze-queue/lib/queue.js:174:5)
    at module.exports (/private/tmp/aurelia-orm/node_modules/breeze-dag/lib/dag.js:118:9)
    at DestroyableTransform.endStream [as _flush] (/private/tmp/aurelia-orm/node_modules/aurelia-tools/src/build.js:42:5)
    at DestroyableTransform.<anonymous> (/private/tmp/aurelia-orm/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:138:49)
    at Object.onceWrapper (events.js:293:19)

If I add the following line of code before the code on this line, everything works as expected:

if (!chunk) return

Never mind the lack of respect for coding style, it was just to test.

I assume my addition isn't needed, so I'm hoping you can tell me what's going on here. I have no idea.

calvinmetcalf commented 7 years ago

this is fixed by nodejs/node#13760 so I think that should be in the next patch version which will be incorporated into this pretty soon after