|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | const common = require('../common'); |
| 4 | +const assert = require('assert'); |
4 | 5 | const { TransformStream } = require('stream/web'); |
5 | 6 | const { setTimeout } = require('timers/promises'); |
6 | 7 |
|
@@ -29,26 +30,24 @@ async function test() { |
29 | 30 | // Late write racing with cancel. |
30 | 31 | const pendingLateWrite = writer.write('late-write'); |
31 | 32 |
|
32 | | - const results = await Promise.allSettled([ |
| 33 | + const [ |
| 34 | + readResult, |
| 35 | + cancelResult, |
| 36 | + lateWriteResult, |
| 37 | + ] = await Promise.allSettled([ |
33 | 38 | pendingRead, |
34 | 39 | pendingCancel, |
35 | 40 | pendingLateWrite, |
36 | 41 | ]); |
37 | 42 |
|
38 | | - // pendingRead should fulfill (with done:true or a value). |
39 | | - // pendingCancel should fulfill. |
40 | | - // pendingLateWrite may reject, but must NOT reject with an internal |
41 | | - // TypeError about transformAlgorithm not being a function. |
42 | | - for (const result of results) { |
43 | | - if (result.status === 'rejected') { |
44 | | - const err = result.reason; |
45 | | - if (err instanceof TypeError && |
46 | | - /transformAlgorithm is not a function/.test(err.message)) { |
47 | | - throw new Error( |
48 | | - 'Internal implementation error leaked: ' + err.message |
49 | | - ); |
50 | | - } |
51 | | - } |
| 43 | + assert.strictEqual(readResult.status, 'fulfilled'); |
| 44 | + assert.strictEqual(cancelResult.status, 'fulfilled'); |
| 45 | + if (lateWriteResult.status === 'rejected') { |
| 46 | + const err = lateWriteResult.reason; |
| 47 | + const isNotAFunction = err instanceof TypeError && |
| 48 | + /transformAlgorithm is not a function/.test(err.message); |
| 49 | + assert.ok(!isNotAFunction, |
| 50 | + `Internal implementation error leaked: ${err.message}`); |
52 | 51 | } |
53 | 52 | } |
54 | 53 |
|
|
0 commit comments