From 8d4b2b1288da5f3946ffed2f48f117d35ae6521c Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 11 Jul 2020 14:05:22 +0200 Subject: [PATCH] fixup --- lib/client-base.js | 21 +++++++++++++++++++-- lib/request.js | 9 --------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/client-base.js b/lib/client-base.js index 3bbfbfd6e1c..409f7291636 100644 --- a/lib/client-base.js +++ b/lib/client-base.js @@ -709,9 +709,26 @@ function resume (client) { // Only allow one active request with reset. const pending = client[kQueue][client[kPendingIdx]] - const running = client[kQueue][client[kRunningIdx]] + if (pending.reset) { + const { streaming, body } = pending + + if (streaming) { + if (typeof body.read === 'function') { + body.read(0) + } + const state = body._readableState + if (state && state.ended && state.length === 0) { + pending.reset = false + } else { + return + } + } else { + return + } + } - if (pending.reset || running.reset) { + const running = client[kQueue][client[kRunningIdx]] + if (running.reset) { return } } diff --git a/lib/request.js b/lib/request.js index 127568dec5a..8c0e46215f5 100644 --- a/lib/request.js +++ b/lib/request.js @@ -99,15 +99,6 @@ class Request extends AsyncResource { // to parse the body as a request and provide two responses, corrupting // undici state. this.reset = this.body && (method === 'HEAD' || method === 'GET') - if (this.reset && this.streaming) { - if (typeof body.read === 'function') { - body.read(0) - } - const state = body._readableState - if (state && state.ended && state.length === 0) { - this.reset = false - } - } { // TODO (perf): Build directy into buffer instead of