Closed thatcort closed 2 years ago
I don't know. There seems to be something off with how snowpack is transpiling/compiling/exposing this.
It would likely get fixed once I finish v4.
I can reproduce this using rollup + rollup-plugin-polyfill-node. It also happens using transform streams.
Reproduced the same behavior with rollup and rollup-plugin-polyfill-node
Fixed in v4.0.0 as soon as we ship
I'm getting the following stack trace when I try to run my app in the browser:
The app is built with Snowpack, which uses rollup-plugin-node-polyfills, which uses readable-stream to polyfill Node streams. When I step through the code, I think the problem is with how the Duplex prototype chain is initialized:
Readable.call(this, options) goes to:
Since Readable isn't already in the prototype chain the instanceof check recurses to return a new object. The new object gets initialized, but then passed back up to Duplex, which just throws it away, rather than adding it to its own prototype chain.
I'm not sure what the best fix is. Should Duplex add a call to Object.setPrototypeOf(...)? This instanceof check seems to be used throughout the library, so it seems a bit strange that I would be hitting this issue for the first time, so maybe I'm missing something?