diff --git a/lib/fetch/index.js b/lib/fetch/index.js index 4d38f7a4147..42ece0ad553 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -305,7 +305,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') { // global, and cacheState. markResourceTiming( timingInfo, - originalURL, + originalURL.href, initiatorType, globalThis, cacheState @@ -313,11 +313,9 @@ function finalizeAndReportTiming (response, initiatorType = 'other') { } // https://w3c.github.io/resource-timing/#dfn-mark-resource-timing -function markResourceTiming (timingInfo, originalURL, initiatorType, globalThis, cacheState) { - if (nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 2)) { - performance.markResourceTiming(timingInfo, originalURL.href, initiatorType, globalThis, cacheState) - } -} +const markResourceTiming = (nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 2)) + ? performance.markResourceTiming + : () => {} // https://fetch.spec.whatwg.org/#abort-fetch function abortFetch (p, request, responseObject, error) { @@ -1044,7 +1042,7 @@ function fetchFinale (fetchParams, response) { // and responseStatus. if (fetchParams.request.initiatorType != null) { // TODO: update markresourcetiming - markResourceTiming(timingInfo, fetchParams.request.url, fetchParams.request.initiatorType, globalThis, cacheState, bodyInfo, responseStatus) + markResourceTiming(timingInfo, fetchParams.request.url.href, fetchParams.request.initiatorType, globalThis, cacheState, bodyInfo, responseStatus) } } diff --git a/lib/pool.js b/lib/pool.js index e3cd3399e6b..f52e2854b40 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -76,18 +76,17 @@ class Pool extends PoolBase { } [kGetDispatcher] () { - let dispatcher = this[kClients].find(dispatcher => !dispatcher[kNeedDrain]) - - if (dispatcher) { - return dispatcher + for (const client of this[kClients]) { + if (!client[kNeedDrain]) { + return client + } } if (!this[kConnections] || this[kClients].length < this[kConnections]) { - dispatcher = this[kFactory](this[kUrl], this[kOptions]) + const dispatcher = this[kFactory](this[kUrl], this[kOptions]) this[kAddClient](dispatcher) + return dispatcher } - - return dispatcher } }