nodejs / readable-stream

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

break in BufferList.prototype[inspect.custom] = function () { #355

Closed mitra42 closed 6 years ago

mitra42 commented 6 years ago

A change to readable-stream 3.0.1 from the previous 2.3.6 causes the following bug while loading the webpacked application on a browser, the application then fails to load.

A simple rollback to 2.3.6 fixes this, so it looks like something broken in the major release.

buffer_list.js:155 Uncaught TypeError: Cannot read property 'custom' of undefined
    at eval (buffer_list.js:155)
    at eval (buffer_list.js:161)
    at Object../node_modules/readable-stream/lib/internal/streams/buffer_list.js (dweb-transports-bundle.js:16564)
    at __webpack_require__ (dweb-transports-bundle.js:20)
    at Object.eval (VM3191 _stream_readable.js:63)
    at eval (VM3191 _stream_readable.js:1038)
    at Object../node_modules/readable-stream/lib/_stream_readable.js (dweb-transports-bundle.js:16516)
    at __webpack_require__ (dweb-transports-bundle.js:20)
    at eval (VM3190 readable-browser.js:1)
    at Object../node_modules/readable-stream/readable-browser.js (dweb-transports-bundle.js:16610)

The line in question is break in BufferList.prototype[inspect.custom] = function () { And inspect is defined in:

var _require = __webpack_require__(/*! util */ 1),
    inspect = _require.inspect;

I thought it might be just an undeclared dependency on inspect which I didn't find anywhere in package-lock.json, but even installing inspect (version 0.0.2) doesnt fix it, could it be an unforseen bad interaction with webpack ?

mcollina commented 6 years ago

Thanks for reporting this!

It is the latter, I think their Node compatibility layer has not been updated in a bit of time.

On a side note, I think we should add some tests that verifies webpack compatibility.

Would you mind adding an example so I can verify the fix?

mitra42 commented 6 years ago

I'm not sure how to add a simple example for your test ... haven't worked on readable-streams (just using it in @internetarchive/dweb-transports).