Skip to content

Commit b9b8a96

Browse files
committed
test: cover finished on pre-aborted signal
1 parent bd8ee4b commit b9b8a96

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/parallel/test-stream-finished.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,26 @@ const http = require('http');
9595

9696
{
9797
// Check pre-cancelled
98-
const signal = new EventTarget();
99-
signal.aborted = true;
98+
const signal = AbortSignal.abort();
10099

101100
const rs = Readable.from((function* () {})());
102101
finished(rs, { signal }, common.mustCall((err) => {
103102
assert.strictEqual(err.name, 'AbortError');
104103
}));
105104
}
106105

106+
{
107+
// Check pre-cancelled when eos() must resolve from the signal path.
108+
const signal = AbortSignal.abort();
109+
110+
const rs = new Readable({
111+
read() {}
112+
});
113+
finished(rs, { signal }, common.mustCall((err) => {
114+
assert.strictEqual(err.name, 'AbortError');
115+
}));
116+
}
117+
107118
{
108119
// Check cancelled before the stream ends sync.
109120
const ac = new AbortController();

0 commit comments

Comments
 (0)