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

Call push asyncly after readableStream.on('data', ...) will cause error. #38865

Closed
07akioni opened this issue May 31, 2021 · 4 comments
Closed
Labels
stream Issues and PRs related to the stream subsystem.

Comments

@07akioni
Copy link

  • Version: v14.17.0
  • Platform: Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
  • Subsystem:

What steps will reproduce the bug?

const { Readable } = require("stream");
const readableStream = new Readable();
setTimeout(() => {
  readableStream.push("chunk");
  readableStream.push(null);
}, 1000);
readableStream.on("data", () => {
  console.log("whatever");
});
internal/streams/readable.js:642
  throw new ERR_METHOD_NOT_IMPLEMENTED('_read()');
  ^

Error [ERR_METHOD_NOT_IMPLEMENTED]: The _read() method is not implemented
    at Readable._read (internal/streams/readable.js:642:9)
    at Readable.read (internal/streams/readable.js:481:10)
    at resume_ (internal/streams/readable.js:977:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  code: 'ERR_METHOD_NOT_IMPLEMENTED'
}

How often does it reproduce? Is there a required condition?

Everytimes.

What is the expected behavior?

I'm not quite sure but I won't expect it to have errors after reading the docs.

What do you see instead?

Additional information

@07akioni 07akioni changed the title Call push async after readStream.on('data) will cause error. Call push async after readStream.on('data', ...) will cause error. May 31, 2021
@bl-ue
Copy link
Contributor

bl-ue commented May 31, 2021

cc @nodejs/streams

@07akioni 07akioni changed the title Call push async after readStream.on('data', ...) will cause error. Call push async after readableStream.on('data', ...) will cause error. May 31, 2021
@07akioni 07akioni changed the title Call push async after readableStream.on('data', ...) will cause error. Call push asyncly after readableStream.on('data', ...) will cause error. May 31, 2021
@aduh95
Copy link
Contributor

aduh95 commented May 31, 2021

cc @nodejs/streams

@aduh95 aduh95 added the stream Issues and PRs related to the stream subsystem. label May 31, 2021
@ronag
Copy link
Member

ronag commented May 31, 2021

You need to implement the _read method or at least pass a stub, it's not optional. I think the docs are clear on this (haven't checked)?

@mcollina
Copy link
Member

This is clearly documented.

07akioni added a commit to 07akioni/vue-next that referenced this issue Jun 1, 2021
…an empty _read method.

Nor it will throw errors.

See nodejs/node#38865.

The tests passes in jest before because jest mock the global promise and causes inconsistant behavior compared with native nodejs.
jestjs/jest#11497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

No branches or pull requests

5 participants