Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream polyfill issue: "Error: The _read() method is not implemented" #6846

Closed
fregante opened this issue Aug 31, 2021 · 4 comments · Fixed by #6863
Closed

stream polyfill issue: "Error: The _read() method is not implemented" #6846

fregante opened this issue Aug 31, 2021 · 4 comments · Fixed by #6863

Comments

@fregante
Copy link
Contributor

fregante commented Aug 31, 2021

🐛 bug report

I'm unable to bundle a node package. I receive this error when I run it in the browser:

VM31:1882 Uncaught Error: The _read() method is not implemented
    at new NodeError2 (<anonymous>:3896:26)
    at Readable._read (<anonymous>:1389:26)
    at Readable.read (<anonymous>:1267:14)
    at flow (<anonymous>:1641:35)
    at Readable.pipeOnDrainFunctionResult (<anonymous>:1505:13)
    at Readable.emit (<anonymous>:1890:40)
    at Readable.stream.resume (<anonymous>:903:36)
    at Readable.tr.resume (<anonymous>:9309:23)
    at Readable.on (<anonymous>:1553:43)
    at Readable.pipe (<anonymous>:1451:9)

🎛 Configuration (.babelrc, package.json, cli command)

  1. Create a test.js file:
import test from 'tape';

test('test using promises', t => {
  t.pass();
});
  1. Run these commands
echo '{}' > package.json
npm i tape parcel
npx parcel build test.js
  1. Copy the content of dist/main.js and execute it in the browser, like in the console.

💁 Possible Solution

Fixing the streams polyfill. stream-browserify works in webpack. More context in the issue I opened in the library I was trying to bundle tape-testing/tape#561

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-rc.0
Node v16.4.2
npm/Yarn 7.18.1
Operating System macOS 11.5.2
@mischnic
Copy link
Member

This is the stream polyfill that's used:

exports.stream = require.resolve('readable-stream');

"readable-stream": "^3.6.0",

"browser": { "fs": false }

Parcel essentially does this by default.

So I'm curious if there's something we could change in Parcel to fix this..

@mischnic
Copy link
Member

mischnic commented Sep 1, 2021

Interesting, it works with if it's instead polyfilled with stream-browserify.

This was changed by #4225

@ljharb
Copy link

ljharb commented Sep 1, 2021

I'm confused why #4225 happened - readable-stream isn't a browser package, it was always meant to be a polyfill for older node.

@mischnic
Copy link
Member

mischnic commented Sep 1, 2021

I wish I could remember why 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants