Version
main
Platform
Subsystem
stream
What steps will reproduce the bug?
import { push } from 'node:stream/iter';
async function repro(label, abortBeforeEnd) {
const { writer, readable } = push();
await writer.write('x');
const controller = new AbortController();
if (abortBeforeEnd) controller.abort(new Error('stop'));
const ending = writer.end({ signal: controller.signal }).then(
(bytes) => `resolved: ${bytes}`,
(error) => `rejected: ${error.message}`,
);
if (!abortBeforeEnd) controller.abort(new Error('stop'));
const draining = (async () => {
for await (const chunk of readable) {
void chunk;
}
})();
console.log(`${label}: ${await ending}`);
await draining;
}
await repro('pre-aborted', true);
await repro('aborted while draining', false);
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
it should reject with the signal’s abort reason in both cases.
What do you see instead?
pre-aborted: resolved: 1
aborted while draining: resolved: 1
end() resolves successfully whether the signal is already aborted or becomes aborted while the buffered data is draining.
Additional information
No response
Version
main
Platform
Subsystem
stream
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
it should reject with the signal’s abort reason in both cases.
What do you see instead?
end()resolves successfully whether the signal is already aborted or becomes aborted while the buffered data is draining.Additional information
No response