Skip to content

Commit

Permalink
fix(adapter-node-http): Pause socket on original request (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
offirgolan authored and jasonmit committed Jan 16, 2019
1 parent 12fcfa7 commit 8f0c56c
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ export default class TransportWrapper {
const chunks = [];

response.on('data', chunk => chunks.push(chunk));
response.on('end', () =>
response.once('end', () =>
resolve(this.getBodyFromChunks(chunks, response.headers))
);
response.on('error', reject);
response.once('error', reject);
});

return {
Expand Down Expand Up @@ -214,6 +214,9 @@ export default class TransportWrapper {
const chunks = [];
let ended = false;

// Pause the opened socket so it doesn't read any of the incoming data
req.once('socket', socket => socket.pause());

// Override req.write so we can save all the request body chunks
req.write = (chunk, encoding, callback) => {
if (!req.aborted) {
Expand Down

0 comments on commit 8f0c56c

Please sign in to comment.