From 31d900227d2ea7cb205fd4dc8db0aed5abd0dfa9 Mon Sep 17 00:00:00 2001 From: Denis DelGrosso <85250797+ddelgrosso1@users.noreply.github.com> Date: Fri, 17 Feb 2023 10:02:36 -0500 Subject: [PATCH] fix: use pipeline in place of pipe to better handle cleanup / errors (#299) --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9956e3f..b8dccee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ import {Agent, AgentOptions as HttpsAgentOptions} from 'https'; import {AgentOptions as HttpAgentOptions} from 'http'; import fetch, * as f from 'node-fetch'; -import {PassThrough, Readable} from 'stream'; +import {PassThrough, Readable, pipeline} from 'stream'; import * as uuid from 'uuid'; import {getAgent} from './agents'; import {TeenyStatistics} from './TeenyStatistics'; @@ -263,10 +263,10 @@ function teenyRequest( let responseStream: any; requestStream.once('reading', () => { if (responseStream) { - responseStream.pipe(requestStream); + pipeline(responseStream, requestStream, () => {}); } else { requestStream.once('response', () => { - responseStream.pipe(requestStream); + pipeline(responseStream, requestStream, () => {}); }); } });