Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Cancellation can report a truncated fetch response as successful through duplicate completion, while replacement requests from interceptors can cause a TypeError that prevents cancellation and retry.
2 open issues
What changed in this PR
This PR updates dash.js network loaders to prevent duplicate request handling when fragmentRequestProgressTimeout cancels a download.
Changes:
- Suppresses abort callbacks before progress-timeout cancellation.
- Ignores
AbortErrorrejections from fetch and stream reads. - Corrects the reader-cancellation callback and checks for a null handler.
| File | Description |
|---|---|
src/streaming/net/XHRLoader.js |
Exposes the active XHR so its abort callback can be suppressed. |
src/streaming/net/HTTPLoader.js |
Disables abort handlers and invokes request-specific cancellation on progress timeout. |
src/streaming/net/FetchLoader.js |
Handles abort rejections and corrects the fallback cancellation callback. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Regression tests are missing for XHR and both Fetch cancellation paths to verify that progress timeouts schedule exactly one retry without invoking the caller’s abort callback, including when interceptors replace request data.
2 open issues
1 resolved since last review
Review effort: Balanced
| commonMediaRequest.customData.onabort = null; | ||
| commonMediaRequest.customData.abort(); | ||
| _onloadend(); |
Fixes duplicate requests that resulted from the firing of the progressTimeout - Ignore `AbortError` rejections from Fetch API responses and stream readers. - Expose the active XHR and suppress abort callbacks during progress-timeout cancellation. - Correct fetch reader cancellation to invoke the configured abort handler.
- Normally handlers are set to null when disabled (e.g. by ProgressTimeOut) but since this is an explicit call of onabort a null check is needed beforehand otherwise a TypeError would be raised.
- In the case of an abort() without an AbortController where the stream is cancelled the new `cancelled` variable allows for a graceful exit from the _processResult() handler.
- A RequestInterceptor can replace the httpRequest object so this fix ensures that the commonMediaRequest is set to the new httpRequest
Verify intercepted XHR and Fetch requests are aborted and retried after progress timeouts, including Fetch reader cancellation without AbortController, and confirm explicit aborts target the replacement request.
730a6c3 to
9476b73
Compare
| this.customData.reader.cancel(); | ||
| this.onabort(); | ||
| if (this.customData.onabort) { | ||
| this.customData.onabort(); |
| } | ||
| }); | ||
| const fetchStub = sandbox.stub(window, 'fetch'); | ||
| fetchStub.onFirstCall().resolves(new Response(pendingResponse)); |
There was a problem hiding this comment.
🟡 Changes recommended
Two critical concurrency defects remain in the shared XHR abort handling, allowing one request’s timeout to abort another while leaving the timed-out request active.
5 open issues
Bind timeout aborts to the request's own XHR · New Timeout aborts the wrong XHR when requests overlap · New Aborting requests can skip entries when the active array mutates Abort test stub ignores signal and misses duplicate completion Test progress-timeout retries and abort handling across loader paths
Review effort: Lite
| commonMediaRequest.customData.abortController.signal.onabort = null; | ||
| } | ||
| commonMediaRequest.customData.onabort = null; | ||
| commonMediaRequest.customData.abort(); |
| xhr.onabort = commonMediaRequest.customData.onabort; | ||
| xhr.ontimeout = commonMediaRequest.customData.ontimeout; | ||
| // Expose the live xhr so callers can suppress onabort before a deliberate abort (e.g. progress timeout) | ||
| commonMediaRequest.customData.xhr = xhr; |



Fix fragmentRequestProgressTimeout abort handling
Addresses duplicate requests that resulted from firing of the progressTimeout
AbortErrorrejections from Fetch API responses and stream readers.Add check for null onabort handler