◐ Shell
clean mode source ↗

stream: reject duplicate nested transferables · nodejs/node@cfb1fa9

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,19 @@

1+

'use strict';

2+
3+

require('../common');

4+

const assert = require('node:assert');

5+
6+

const combinations = [

7+

((t) => [t, t.readable])(new TransformStream()),

8+

((t) => [t.readable, t])(new TransformStream()),

9+

((t) => [t, t.writable])(new TransformStream()),

10+

((t) => [t.writable, t])(new TransformStream()),

11+

];

12+
13+

for (const combination of combinations) {

14+

assert.throws(() => structuredClone(combination, { transfer: combination }), {

15+

constructor: DOMException,

16+

name: 'DataCloneError',

17+

code: 25,

18+

});

19+

}