Skip to content

Commit 503dbd8

Browse files
authored
fix: patch TransformStream on Node.js 16 (#564)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced compatibility with Node.js 16 by adding support for `TransformStream`. - **Bug Fixes** - Implemented a polyfill for `TransformStream` to ensure it is available in the global scope if not already defined. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent b5dccce commit 503dbd8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { randomBytes, createHash } from 'node:crypto';
22
import { Readable } from 'node:stream';
33
import { performance } from 'node:perf_hooks';
4-
import { ReadableStream } from 'node:stream/web';
4+
import { ReadableStream, TransformStream } from 'node:stream/web';
55
import { Blob } from 'node:buffer';
66
import type { FixJSONCtlChars } from './Request.js';
77
import { SocketInfo } from './Response.js';
@@ -216,6 +216,11 @@ export function patchForNode16() {
216216
// @ts-ignore
217217
global.ReadableStream = ReadableStream;
218218
}
219+
if (typeof global.TransformStream === 'undefined') {
220+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
221+
// @ts-ignore
222+
global.TransformStream = TransformStream;
223+
}
219224
if (typeof global.Blob === 'undefined') {
220225
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
221226
// @ts-ignore

0 commit comments

Comments
 (0)