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: readable.compose fails to return a Duplex #55203

Open
Renegade334 opened this issue Oct 1, 2024 · 1 comment · May be fixed by #55394
Open

stream: readable.compose fails to return a Duplex #55203

Renegade334 opened this issue Oct 1, 2024 · 1 comment · May be fixed by #55394
Labels
stream Issues and PRs related to the stream subsystem.

Comments

@Renegade334
Copy link
Contributor

The intention of readable.compose() is that the method returns the Duplex from the internals/streams/compose function unscathed.

Unfortunately, because it's merged onto Readable.prototype as a "stream-returning operator":

node/lib/stream.js

Lines 64 to 83 in 8a3482e

const streamKeys = ObjectKeys(streamReturningOperators);
for (let i = 0; i < streamKeys.length; i++) {
const key = streamKeys[i];
const op = streamReturningOperators[key];
function fn(...args) {
if (new.target) {
throw new ERR_ILLEGAL_CONSTRUCTOR();
}
return Stream.Readable.from(ReflectApply(op, this, args));
}
ObjectDefineProperty(fn, 'name', { __proto__: null, value: op.name });
ObjectDefineProperty(fn, 'length', { __proto__: null, value: op.length });
ObjectDefineProperty(Stream.Readable.prototype, key, {
__proto__: null,
value: fn,
enumerable: false,
configurable: true,
writable: true,
});
}

...its return value is passed via Readable.from(), clobbering the Duplex into a Readable.

The .compose() operator needs specifically to bypass this mechanism.

Refs: #44937

@debadree25 debadree25 added the stream Issues and PRs related to the stream subsystem. label Oct 1, 2024
@BetaDude40
Copy link

I can try and work on this

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

Successfully merging a pull request may close this issue.

3 participants