mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8f742bb13f
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>
25 lines
729 B
JavaScript
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());
|
|
}
|