Skip to content

fragmentRequestProgressTimeout fix - #5192

Open
piersoh wants to merge 6 commits into
Dash-Industry-Forum:developmentfrom
piersoh:progress-timer-fix
Open

piersoh wants to merge 6 commits into
Dash-Industry-Forum:developmentfrom
piersoh:progress-timer-fix

Conversation

@piersoh

@piersoh piersoh commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Fix fragmentRequestProgressTimeout abort handling

  • Addresses duplicate requests that resulted from 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.
  • Add check for null onabort 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.
    • Updated comments WRT AbortController with older Chrome vs Firefox

Copilot AI balanced review requested due to automatic review settings November 2, 2026 12:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 AbortError rejections 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

Comment thread src/streaming/net/HTTPLoader.js Resolved
Comment thread src/streaming/net/HTTPLoader.js Resolved
@dsilhavy dsilhavy added this to the 5.3.1 milestone Nov 4, 2026
@piersoh
piersoh requested a balanced review from Copilot November 10, 2026 14:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment on lines +210 to 212
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The abort path can skip a second in-flight Fetch request when AbortController is unavailable, and the abort-signal test does not reliably catch duplicate completion.

3 open issues
1 resolved since last review

Review effort: Balanced

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));

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

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;

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Two critical active findings remain because timeout aborts are not request-specific when concurrent XHRs share a loader, allowing the wrong request to continue and overlap retries.

5 open issues

Review effort: Lite

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants