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: allow infinite concurrency #48588

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rluvaton
Copy link
Member

@rluvaton rluvaton commented Jun 28, 2023

adding this so we can use it in:

which is needed as we don't want to wait for the prev tests to finish before starting a new one (same issue as in #46132)

This has a pitfall in using concurrency: Infinity on infinite stream

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jun 28, 2023
@rluvaton
Copy link
Member Author

rluvaton commented Jun 28, 2023

the macOS failed test is unrelated:
test-inspector-debug-end.js

{
// Allow Infinite concurrency
const stream = Readable.from([1, 2]).map(async (item, { signal }) => {
await setTimeout(10 - item, { signal });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this asserts concurrency works

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test meant to make sure that concurrency: Infinity does not throw an error, but you are right, it does not test that concurrency works, fixed it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a timer here? Can't this just be something like:

let count = 0; // or t.mock
Readable.from(Array(1000).fill()).map(() => {
  count++;
  return new Promise(() => {});
}, { concurrency: Infinity }).toArray().catch(common.mustNotCall());

await setImmediate(); // from timers/promises
strictEqual(count, 1000);

@rluvaton rluvaton requested a review from MoLow June 29, 2023 14:04
@benjamingr
Copy link
Member

@ronag I'm not sure about this wdyt?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any good reason to allow this API: it's a gateway to memory leaks.

@ljharb
Copy link
Member

ljharb commented Jun 29, 2023

How is it different than allowing Number.MAX_SAFE_INTEGER?

@rluvaton
Copy link
Member Author

I don't see any good reason to allow this API: it's a gateway to memory leaks.

@mcollina we can log a warning in case the array reaches some size like what's happening when having a lot of listeners to event emitter

@MoLow
Copy link
Member

MoLow commented Jul 2, 2023

we can log a warning in case the array reaches some size like what's happening when having a lot of listeners to event emitter

then why add this option in the first place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants