node/test/parallel/test-webstream-readablestream-pipeto.js
Antoine du Hamel 8f742bb13f
test: ensure never settling promises are detected
PR-URL: https://github.com/nodejs/node/pull/50318
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-10-23 17:55:50 +00:00

25 lines
729 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('node:assert');
const { AbortError } = require('internal/errors');
// Purpose: pass an AbortError instance, which isn't the DOMException, as an
// abort reason.
for (const message of [undefined, 'abc']) {
const rs = new ReadableStream();
const ws = new WritableStream();
const ac = new AbortController();
const reason = new AbortError(message);
ac.abort(reason);
assert.rejects(rs.pipeTo(ws, { signal: ac.signal }), (e) => {
assert(e instanceof DOMException);
assert.strictEqual(e.name, 'AbortError');
assert.strictEqual(e.message, reason.message);
return true;
}).then(common.mustCall());
}