From ceeb264361c4b21079688ba0045962beeb191d66 Mon Sep 17 00:00:00 2001 From: vlazh Date: Fri, 15 Nov 2024 19:43:37 +0500 Subject: [PATCH] fix: Calculate timeToFirstByte before fire the event 'downloadheadersreceived' (#7605) Fixes #7604 --- lib/net/networking_engine.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/net/networking_engine.js b/lib/net/networking_engine.js index 2b399360a0..b6b1947293 100644 --- a/lib/net/networking_engine.js +++ b/lib/net/networking_engine.js @@ -576,12 +576,12 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget { } }; const headersReceived = (headers) => { - if (this.onHeadersReceived_) { - this.onHeadersReceived_(headers, request, type); - } headersReceivedCalled = true; request.timeToFirstByte = Date.now() - /** @type {number} */ (request.requestStartTime); + if (this.onHeadersReceived_) { + this.onHeadersReceived_(headers, request, type); + } }; request.requestStartTime = Date.now();