Skip to content

Commit 23c602d

Browse files
test if undefined instead of typeof. use node:test and assert
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
1 parent a84a506 commit 23c602d

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

lib/internal/webstreams/transformstream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ function transformStreamDefaultControllerError(controller, error) {
524524
async function transformStreamDefaultControllerPerformTransform(controller, chunk) {
525525
try {
526526
const transformAlgorithm = controller[kState].transformAlgorithm;
527-
if (typeof transformAlgorithm !== 'function') {
527+
if (transformAlgorithm === undefined) {
528528
// Algorithms were cleared by a concurrent cancel/abort/close.
529529
return;
530530
}

test/parallel/test-whatwg-transformstream-cancel-write-race.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
'use strict';
22

3-
const common = require('../common');
4-
const assert = require('assert');
3+
require('../common');
4+
const { test } = require('node:test');
5+
const assert = require('node:assert');
56
const { TransformStream } = require('stream/web');
67
const { setTimeout } = require('timers/promises');
78

8-
// Test for https://github.com/nodejs/node/issues/62036
9-
// A late write racing with reader.cancel() should not throw an
10-
// internal "transformAlgorithm is not a function" TypeError.
9+
// https://github.com/nodejs/node/issues/62036
1110

12-
async function test() {
11+
test('Late write racing with reader.cancel() should not throw an internal TypeError', async () => {
1312
const stream = new TransformStream({
1413
transform(chunk, controller) {
1514
controller.enqueue(chunk);
@@ -49,6 +48,4 @@ async function test() {
4948
assert.ok(!isNotAFunction,
5049
`Internal implementation error leaked: ${err.message}`);
5150
}
52-
}
53-
54-
test().then(common.mustCall());
51+
});

0 commit comments

Comments
 (0)