Skip to content

Commit

Permalink
fix: use pipeline in place of pipe to better handle cleanup / errors (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelgrosso1 committed Feb 17, 2023
1 parent fdecde6 commit 31d9002
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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, () => {});
});
}
});
Expand Down

0 comments on commit 31d9002

Please sign in to comment.