Skip to content

feat: time out requests of the REST providers - #600

Open
uniqueg wants to merge 17 commits into
devfrom
feat/599-request-timeout
Open

uniqueg wants to merge 17 commits into
devfrom
feat/599-request-timeout

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Give every request of the REST providers a deadline, so that a server that accepts the connection but never answers makes the request reject and the components show their usual error, instead of loading forever.

  • Shared helper (@elixir-cloud/design/utils, next to the problem details utilities, which registers no components): fetchWithTimeout(input, init?, timeout?) aborts the request with a RequestTimeoutError (Request timed out after <n> ms, with timeout) once the deadline expires; the deadline also covers reading the body. The timer is unrefed in Node, the listener on a caller signal is removed when the deadline expires, and a plain AbortError from fetch maps to the timeout error. A signal of the caller (in init or of a Request) still aborts with its own reason. resolveRequestTimeout(options) reads { timeout?: number } (default DEFAULT_REQUEST_TIMEOUT = 30 s, 0 for none; RangeError unless an integer from 0 to 2^31 - 1, as longer timers fire at once).
  • Providers (one commit each, to keep conflicts with the open component PRs small): RestServiceRegistryProvider, RestCloudRegistryProvider, RestTesProvider, RestWesProvider, RestTrsProvider, RestTrsFilerProvider, RestDrsProvider, RestDrsFilerProvider take options as a second constructor argument, expose timeout, and send requests through the helper in their existing fetch() hook. Subclasses that override fetch() and call super.fetch() (the documented auth pattern) keep the deadline. Components that build their provider from baseUrl get the default.
  • Custom providers keep control over their own deadlines; the docs say they should reject instead of never settling.
  • Docs: new page design/request-timeouts.mdx (Request timeouts) in the design docs, with a warning that a timed-out create request may still have succeeded; the constructor option and a note on custom providers in the providers page of Cloud Registry, Service Registry, TES, WES, TRS and TRS-Filer (DRS and DRS-Filer have no providers pages; the request timeouts page shows their constructors); a Timeouts section in the providers overview.
  • Changesets: minor for design and each client package.

Only the providers' requests are covered: direct fetch calls in components (TRS tool files, WES run log files) are not provider requests and keep their behaviour.

For anuragxxd

Choices to confirm or change:

  1. The helper lives in @elixir-cloud/design/utils, which all client packages already depend on (as for the problem details utilities of feat(design): show field errors from the API #576), rather than one copy per package.
  2. Default 30 s, total deadline including the body. runWorkflow() of WES uploads attachments within the same deadline; the WES docs and changeset say to raise it for large attachments. A longer default (e.g. 60 s), or no deadline for uploads, is a one-line change.
  3. timeout is a constructor option (new RestTrsProvider(url, { timeout: 10_000 })), not a component attribute; components with baseUrl use the default.

Verification

  • npm ci, npx turbo run build --filter='./packages/*': all 9 packages build (TypeScript 4.3).
  • node scripts/check-design-utils.mjs: @elixir-cloud/design/utils: ok (new exports listed).
  • npx eslint . in every changed package: 0 errors (warnings only, all in unchanged files); the husky pre-commit npm run lint passed on every commit; prettier --check on the changed files.
  • Tests per package with web-test-runner, Chromium and Firefox (WebKit can't run locally: Playwright has no WebKit build for Ubuntu 26.04; CI runs it):
    • design: all passed except GlobalStyles > code editor theme > draws fold arrows in local Chromium (unchanged code); request-timeout 19 passed in both browsers after the review fixes
    • cloud-registry 144, service-registry 97, tes 58, wes 13, trs 48, trs-filer 62, drs 30: all passed
  • New tests: helper (deadline, default 30 s with fake timers, body deadline via the signal, 0, caller signal and Request signal, validation); each provider (default, invalid timeout, read and write calls reject with RequestTimeoutError, super.fetch() override keeps the deadline and its headers, 0 sends no signal); components with an expired request: SR services and TRS tools and DRS objects show the error and fire their changed event with empty data, TES runs shows the error.
  • DRS-Filer has no test setup (no test script), so its provider change has no test of its own; it is the same change as the DRS provider's.

CI: all checks passed on e58aa0d (after the Sourcery fixes), as before on 11984e8 (Lint, Test on Node 22 and 24 in Chromium, Firefox and WebKit, CodeQL, Codecov patch and project, Read the Docs build), gate CI passed.

Declined review findings

Two rounds of adversarial and quality review; all high/medium findings fixed (timer kept Node processes alive, listener leak on long-lived caller signals, no warning about timed-out create requests, retry docs), plus cheap lows. Declined:

  • Shared test helper for the neverAnswer fetch stub repeated in the test files: each package is its own test root and the repo has no shared test-utility package; a new one is a test-infrastructure choice for anuragxxd.
  • TES runs test doesn't assert an empty ecc-runs-changed event: the TES runs component doesn't fire it on any failure today; changing that is component behaviour outside this issue.
  • Lower bound on the @elixir-cloud/design dependency (*): scripts/release.js pin pins the @elixir-cloud/* dependencies to the released version at release time.
  • Deadlines for direct fetch calls in components (WES run logs, TRS tool files): not provider requests; outside this issue.
  • A test against native fetch with a server that never answers: needs a test-server route in web-test-runner (test-infrastructure choice); the abort-reason-less path is covered with a stubbed AbortController instead.
    Sourcery (threads answered and resolved): fixed the retry example (no retry of timed-out writes), cross-realm Request signals, signal: null overriding a Request signal, and releasing timer and listener when fetch rejects. Declined: (1) a stalled error body after an error status keeps reporting the HTTP status, which the server did send, rather than a timeout; (2) mapping a plain AbortError back to the caller's reason in browsers without abort reasons: that reason is already lost there, as with native fetch; (3) the TRS tool component showing "No files available" on any getToolFiles() failure: existing component behaviour, outside this issue (a follow-up issue is drafted).

Closes #599

🤖 Generated with Claude Code

Summary by Sourcery

Add configurable 30-second deadlines to REST-provider requests and shared utilities so stalled requests reject instead of leaving components loading indefinitely.

New Features:

  • Add shared request-timeout utilities with configurable deadlines and a dedicated timeout error.
  • Add configurable default request deadlines to all REST providers across the client packages.
  • Expose timeout failures through existing component error handling when provider requests expire.

Bug Fixes:

  • Prevent REST-provider requests from remaining pending indefinitely when servers accept connections without responding.

Enhancements:

  • Preserve caller cancellation and subclassed provider fetch behavior while allowing timeouts to be disabled.

Documentation:

  • Document provider timeout configuration, custom-provider responsibilities, timeout-aware retries, and the risk of retrying timed-out write requests.

Tests:

  • Add coverage for timeout utility behavior, provider request types, cancellation, validation, body deadlines, and component error states.

Chores:

  • Add minor-release changesets for the shared design utilities and all affected client packages.

uniqueg and others added 2 commits November 18, 2026 10:18
Add fetchWithTimeout(), RequestTimeoutError and
resolveRequestTimeout() to @elixir-cloud/design/utils, for the REST
providers of the client packages to give each request a deadline
(default 30 s, 0 for none). The deadline covers reading the body too;
a signal of the caller still aborts with its own reason.

Document them on a new "Request timeouts" page of the design docs.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RestServiceRegistryProvider takes an options argument with timeout
(milliseconds, default 30 s, 0 for none) and sends every request with
fetchWithTimeout(), so a server that never answers makes the request
reject with a RequestTimeoutError and the components show an error
instead of loading forever. Overrides of fetch() that call
super.fetch() keep the deadline.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

API

Add the exported timeout utility API and give every REST provider a configurable timeout while routing its requests through the shared helper.

  • packages/ecc-client-elixir-cloud-registry/src/providers/rest-cr-provider.ts L1-5, L27-48
  • packages/ecc-client-elixir-drs-filer/src/providers/rest-drs-filer-provider.ts L1-5, L20-41
  • packages/ecc-client-elixir-trs-filer/src/providers/rest-trs-filer-provider.ts L1-5, L24-45
  • packages/ecc-client-ga4gh-drs/src/providers/rest-drs-provider.ts L1-5, L13-34
  • packages/ecc-client-ga4gh-service-registry/src/providers/rest-sr-provider.ts L1-5, L18-39
  • packages/ecc-client-ga4gh-tes/src/providers/rest-tes-provider.ts L1-5, L25-44
  • packages/ecc-client-ga4gh-trs/src/providers/rest-trs-provider.ts L1-5, L21-42
  • packages/ecc-client-ga4gh-wes/src/providers/rest-wes-provider.ts L1-5, L24-43
  • packages/ecc-utils-design/src/utils/index.ts L2
  • packages/ecc-utils-design/src/utils/request-timeout.ts L1-139

UI

Verify that components surface provider timeout failures through their existing error states and empty-data events.

  • packages/ecc-client-ga4gh-drs/src/components/objects-list/tests/objects.test.ts L6, L12-17, L234-251
  • packages/ecc-client-ga4gh-service-registry/src/components/services/tests/services-provider.test.ts L45-50, L261-279
  • packages/ecc-client-ga4gh-tes/src/components/runs/runs.test.ts L10-16, L355-373
  • packages/ecc-client-ga4gh-trs/src/components/tools/tests/tools.test.ts L7-13, L280-296

Configuration

Record the minor releases for the timeout utilities and each affected client package, and extend the utility-export check.

  • .changeset/cloud-registry-request-timeout.md L1-5
  • .changeset/design-request-timeout.md L1-5
  • .changeset/drs-filer-request-timeout.md L1-5
  • .changeset/drs-request-timeout.md L1-5
  • .changeset/service-registry-request-timeout.md L1-5
  • .changeset/tes-request-timeout.md L1-5
  • .changeset/trs-filer-request-timeout.md L1-5
  • .changeset/trs-request-timeout.md L1-5
  • .changeset/wes-request-timeout.md L1-5
  • scripts/check-design-utils.mjs L9-10, L15

Documentation

Document the timeout option, defaults, custom-provider expectations, timeout errors, and cautions around retrying timed-out mutations.

  • apps/documentation/pages/docs/cloud-registry/providers.mdx L52, L57
  • apps/documentation/pages/docs/design/_meta.json L5-6
  • apps/documentation/pages/docs/design/request-timeouts.mdx L1-58
  • apps/documentation/pages/docs/providers.mdx L283-284, L301-310, L328-341
  • apps/documentation/pages/docs/service-registry/providers.mdx L38, L43
  • apps/documentation/pages/docs/tes/providers.mdx L37, L43
  • apps/documentation/pages/docs/trs-filer/providers.mdx L82, L87
  • apps/documentation/pages/docs/trs/providers.mdx L67, L72
  • apps/documentation/pages/docs/wes/providers.mdx L36, L41

Tests

Cover timeout validation, cancellation and body deadlines in the shared utility, and verify timeout behavior and configuration across the REST providers.

  • packages/ecc-client-elixir-cloud-registry/src/providers/tests/rest-cr-provider-timeout.test.ts L1-96
  • packages/ecc-client-elixir-trs-filer/src/providers/tests/rest-trs-filer-provider-timeout.test.ts L1-99
  • packages/ecc-client-ga4gh-drs/src/providers/tests/rest-drs-provider-timeout.test.ts L1-96
  • packages/ecc-client-ga4gh-service-registry/src/providers/tests/rest-sr-provider.test.ts L4-7, L39-45, L94-143
  • packages/ecc-client-ga4gh-tes/src/providers/tests/rest-tes-provider-timeout.test.ts L1-96
  • packages/ecc-client-ga4gh-trs/src/providers/tests/rest-trs-provider-timeout.test.ts L1-95
  • packages/ecc-client-ga4gh-wes/src/providers/tests/rest-wes-provider-timeout.test.ts L1-96
  • packages/ecc-utils-design/src/utils/index.test.ts L15-21
  • packages/ecc-utils-design/src/utils/request-timeout.test.ts L1-302

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.65870% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.69%. Comparing base (f02ed1c) to head (643a480).

Files with missing lines Patch % Lines
...ages/ecc-utils-design/src/utils/request-timeout.ts 99.28% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #600      +/-   ##
==========================================
+ Coverage   78.31%   78.69%   +0.37%     
==========================================
  Files          78       79       +1     
  Lines       19928    20181     +253     
  Branches     1350     1391      +41     
==========================================
+ Hits        15607    15881     +274     
+ Misses       4300     4280      -20     
+ Partials       21       20       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

uniqueg and others added 11 commits November 18, 2026 10:43
RestCloudRegistryProvider takes an options argument with timeout (milliseconds,
default 30 s, 0 for none) and sends every request with
fetchWithTimeout(), so a server that never answers makes the request
reject with a RequestTimeoutError and the components show an error
instead of loading forever. Overrides of fetch() that call
super.fetch() keep the deadline.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RestTesProvider takes an options argument with timeout (milliseconds,
default 30 s, 0 for none) and sends every request with
fetchWithTimeout(), so a server that never answers makes the request
reject with a RequestTimeoutError and the components show an error
instead of loading forever. Overrides of fetch() that call
super.fetch() keep the deadline.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RestWesProvider takes an options argument with timeout (milliseconds,
default 30 s, 0 for none) and sends every request with
fetchWithTimeout(), so a server that never answers makes the request
reject with a RequestTimeoutError and the components show an error
instead of loading forever. Overrides of fetch() that call
super.fetch() keep the deadline.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RestTrsProvider takes an options argument with timeout (milliseconds,
default 30 s, 0 for none) and sends every request with
fetchWithTimeout(), so a server that never answers makes the request
reject with a RequestTimeoutError and the components show an error
instead of loading forever. Overrides of fetch() that call
super.fetch() keep the deadline.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RestTrsFilerProvider takes an options argument with timeout (milliseconds,
default 30 s, 0 for none) and sends every request with
fetchWithTimeout(), so a server that never answers makes the request
reject with a RequestTimeoutError and the components show an error
instead of loading forever. Overrides of fetch() that call
super.fetch() keep the deadline.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RestDrsProvider takes an options argument with timeout (milliseconds,
default 30 s, 0 for none) and sends every request with
fetchWithTimeout(), so a server that never answers makes the request
reject with a RequestTimeoutError and the components show an error
instead of loading forever. Overrides of fetch() that call
super.fetch() keep the deadline.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RestDrsFilerProvider takes an options argument with timeout (milliseconds,
default 30 s, 0 for none) and sends every request with
fetchWithTimeout(), so a server that never answers makes the request
reject with a RequestTimeoutError and the components show an error
instead of loading forever. Overrides of fetch() that call
super.fetch() keep the deadline.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a Timeouts section to the providers overview: the default deadline
of the REST providers, the timeout option, and that custom providers
should reject rather than stay pending.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the review of the branch:

- Unref the deadline timer, so that it doesn't keep Node processes
  (SSR, tests) alive after a request.
- Stop following the caller's signal once the deadline expires, so a
  long-lived signal doesn't collect listeners.
- Reject with the RequestTimeoutError also where fetch rejects with a
  plain AbortError instead of the abort reason.
- Say why the timer isn't cleared when the response arrives.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Warn that a timed-out create request may still have succeeded, and
  that such requests shouldn't be retried automatically.
- Say that the deadline applies per attempt in the retry example.
- Show the constructors of the DRS and DRS-Filer providers, which have
  no providers page.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep the RequestTimeoutError in a variable, so that a plain AbortError
from fetch maps to it also in browsers whose signals drop the abort
reason. Say that reading the body rejects with an AbortError there.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@uniqueg
uniqueg requested a review from anuragxxd November 18, 2026 10:56
@uniqueg uniqueg self-assigned this Nov 18, 2026
@uniqueg
uniqueg marked this pull request as ready for review November 18, 2026 10:56
@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 643a480

#599 feat: time out requests of the REST providers · 4 of 4 met

# Requirement Status Notes
1 Add an optional timeout to REST providers so expired requests reject and components show their usual error. ✅ Met All eight listed REST providers accept timeout options and use fetchWithTimeout(); tests cover provider timeouts and component error display.
2 Document that custom providers control their own deadlines and should reject instead of never settling. ✅ Met The new design request-timeouts page says custom providers must set their own deadline and their methods should reject rather than stay pending.
3 Test that an expired request shows the error and emits the empty data event. ✅ Met Timeout component tests assert the error and empty changed-event data for Service Registry, TRS tools, and DRS objects.
4 Document the timeout option in the providers docs of each package. ✅ Met Provider pages document the option where available; the shared request-timeouts page covers DRS and DRS-Filer, which have no providers pages.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 7 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/ecc-client-ga4gh-tes/src/providers/rest-tes-provider.ts" line_range="44" />
<code_context>
-  // eslint-disable-next-line class-methods-use-this
   protected fetch(input: RequestInfo | URL, init?: RequestInit) {
-    return fetch(input, init);
+    return fetchWithTimeout(input, init, this.timeout);
   }

</code_context>
<issue_to_address>
**Non-OK timeouts become generic errors**

When a REST provider receives a non-2xx response whose body stalls past the deadline, tES/WES response handlers replace body-read timeout errors with generic HTTP errors, and Cloud Registry converts the abort to empty error details, so callers do not receive a recognizable `RequestTimeoutError`.

Preserve and propagate timeout errors when handling non-2xx response bodies across these providers.

Also at `packages/ecc-client-ga4gh-wes/src/providers/rest-wes-provider.ts:43`, `packages/ecc-client-elixir-cloud-registry/src/providers/rest-cr-provider.ts:48`, `packages/ecc-utils-design/src/utils/request-timeout.ts:125`.
</issue_to_address>

### Comment 2
<location path="apps/documentation/pages/docs/providers.mdx" line_range="314" />
<code_context>
 const provider = new RetryableProvider('https://api.example.com');
 ```

+The provider's request deadline (see [Timeouts](#timeouts)) applies to each attempt through `super.fetch()`, not to the retried call as a whole: that can take up to the number of attempts times the deadline, plus the delays. Retry only requests that are safe to repeat: a timed-out request that creates something may still have succeeded on the server.
+
+#### Timeouts
</code_context>
<issue_to_address>
**Timed-out submissions create duplicate runs**

When the documented retry wrapper is used for `RestWesProvider` and a `runWorkflow()` POST reaches the server but its response exceeds the deadline, `RequestTimeoutError` has no HTTP status, so the documented generic retry wrapper treats it as retryable and calls `runWorkflow()` again. If the first POST was accepted before its response timed out, both requests create workflow runs and the caller sees duplicate runs.

Make the retry example restrict retries to safe operations or explicitly exclude timeouts and other ambiguous failures for create requests.

Also at `packages/ecc-client-ga4gh-wes/src/providers/rest-wes-provider.ts:43`.
</issue_to_address>

### Comment 3
<location path="packages/ecc-utils-design/src/utils/request-timeout.ts" line_range="101" />
<code_context>
+  }
+  const controller = new AbortController() as AbortControllerWithReason;
+  const signal = (init.signal ??
+    (input instanceof Request ? input.signal : undefined)) as
+    | AbortSignalWithReason
+    | undefined;
</code_context>
<issue_to_address>
**Cross-frame cancellation is ignored**

When `fetchWithTimeout()` receives a `Request` from another realm without `init.signal`, and the caller aborts that request’s signal, the `instanceof Request` check misses the request’s signal, so `fetchWithTimeout()` passes its own signal to `fetch()` and the caller’s cancellation is ignored until the deadline.

Read the signal from cross-realm `Request` inputs without relying on the current realm’s `Request` constructor.
</issue_to_address>

### Comment 4
<location path="packages/ecc-utils-design/src/utils/request-timeout.ts" line_range="100-101" />
<code_context>
+    return fetch(request, init);
+  }
+  const controller = new AbortController() as AbortControllerWithReason;
+  const signal = (init.signal ??
+    (input instanceof Request ? input.signal : undefined)) as
+    | AbortSignalWithReason
+    | undefined;
</code_context>
<issue_to_address>
**Explicit signal opt-out still aborts**

When the input is a `Request` with an aborted signal and the caller passes `{ signal: null }`, `fetchWithTimeout()` falls back to the input `Request`'s signal when `init.signal` is explicitly `null`. An already-aborted input signal therefore aborts the helper's controller, and the request rejects instead of honoring the caller's signal override.

Distinguish an omitted `init.signal` from an explicitly null one, and do not follow the input signal when the caller supplies null.
</issue_to_address>

### Comment 5
<location path="packages/ecc-utils-design/src/utils/request-timeout.ts" line_range="118" />
<code_context>
+  (timer as { unref?: () => void }).unref?.();
+  function followSignal() {
+    clearTimeout(timer);
+    controller.abort(signal?.reason);
+  }
+  if (signal?.aborted) {
</code_context>
<issue_to_address>
**Caller abort reason is lost**

When a caller aborts with a custom reason in a browser that does not support abort reasons, `followSignal()` passes the caller’s reason to `AbortController.abort()`, but browsers without abort-reason support discard it; `fetch()` then rejects with a plain `AbortError` rather than the caller’s reason, contrary to the helper’s documented signal behavior.

Track caller-abort state and its reason, and map a plain `AbortError` back to that reason when the caller signal caused the abort.
</issue_to_address>

### Comment 6
<location path="packages/ecc-utils-design/src/utils/request-timeout.ts" line_range="125-129" />
<code_context>
+  } else {
+    signal?.addEventListener("abort", followSignal, { once: true });
+  }
+  return fetch(request, { ...init, signal: controller.signal }).catch(
+    (error: unknown) => {
+      // Fetch implementations that reject with a plain `AbortError`
+      // instead of the abort reason still reject with the timeout error
+      throw timeoutError ?? error;
+    }
+  );
</code_context>
<issue_to_address>
**Failed requests retain resources**

When the underlying fetch rejects before its deadline, the rejection handler rethrows without clearing the timer or removing `followSignal` from the caller’s signal, so each failed request retains a timer and listener until the deadline.

Clear the timer and remove the caller-signal listener before rethrowing a fetch error.
</issue_to_address>

### Comment 7
<location path="packages/ecc-client-ga4gh-trs/src/providers/rest-trs-provider.ts" line_range="42" />
<code_context>
-  // eslint-disable-next-line class-methods-use-this
   protected fetch(input: RequestInfo | URL, init?: RequestInit) {
-    return fetch(input, init);
+    return fetchWithTimeout(input, init, this.timeout);
   }

</code_context>
<issue_to_address>
**File-list timeouts are hidden**

When the TRS tool component’s `getToolFiles()` request times out, `getToolFiles()` rejects with the timeout, but `ECCClientGa4ghTrsTool.loadToolFiles()` catches the rejection and only logs it; the component then renders “No files available” rather than an error, so users can mistake a failed request for an empty result.

Set and render an error state (and emit the appropriate failure event, if applicable) in `loadToolFiles()` when the request fails.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 7 findings to address first, and if a valid create or workflow request exceeds the deadline, the client can report a timeout even though the server completes the operation, leaving a task or resource the caller may submit again. Reverting stops future timeouts but cannot undo operations the server already completed; these effects are bounded and can generally be checked or cleaned up.

Blocking findings: packages/ecc-client-ga4gh-tes/src/providers/rest-tes-provider.ts:44, apps/documentation/pages/docs/providers.mdx:314, packages/ecc-utils-design/src/utils/request-timeout.ts:101, packages/ecc-utils-design/src/utils/request-timeout.ts:101, packages/ecc-utils-design/src/utils/request-timeout.ts:118, and 2 more


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

uniqueg and others added 2 commits November 18, 2026 12:17
From the automated review:

- Read the signal of a Request without instanceof, so that requests
  of other realms (iframes) are followed too.
- Let a signal in init replace the Request's even when it is null, as
  fetch does.
- Release the timer and the caller's signal when fetch rejects.
- Don't repeat timed-out requests other than GET and HEAD in the retry
  example of the providers docs.

Refs #599

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflict in the TRS tools list tests by keeping both
sides: the timeout test of this branch and the tool class filter
tests of #587.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

New gaps against the linked issues

@anuragxxd

Copy link
Copy Markdown
Member

Thanks @uniqueg, tested locally: every package passes in all three browsers, and against a server that never answers the components now show the timeout error instead of loading forever.

On your question 2: please exempt runWorkflow() from the deadline and keep 30 s for all other requests.

It's the only request that uploads user files, so a 30 s total deadline behaves differently there:

  1. Its duration depends on file size, not on whether the server is alive. A 50 MB attachment on a 10 Mbit/s uplink takes about 40 s to send, so it fails every time even with a healthy server. fetch doesn't report upload progress, so we can't start the deadline after the upload instead.
  2. A timeout there isn't harmless. The server may already have created the run, so the user's retry creates a second run.

The other creates (TES, TRS-Filer, DRS-Filer) send small JSON, so 30 s there really does mean a broken server.

Suggested change: an optional third timeout argument to the providers' fetch(), with runWorkflow() passing 0. Subclasses that override fetch() with two arguments keep the 30 s, so nothing gets worse. Please add a test that runWorkflow() sends no deadline.

I've also trimmed the docs and changesets: one line per provider page instead of the repeated paragraphs, a shorter Request timeouts page, and one-sentence changesets. I've pushed that to the branch. Hope that's fine.

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

None yet

Development

Successfully merging this pull request may close these issues.

feat: time out requests of the REST providers

2 participants