Repository navigation
Conversation
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>
Reviewer's GuideAPIAdd the exported timeout utility API and give every REST provider a configurable timeout while routing its requests through the shared helper.
UIVerify that components surface provider timeout failures through their existing error states and empty-data events.
ConfigurationRecord the minor releases for the timeout utilities and each affected client package, and extend the utility-export check.
DocumentationDocument the timeout option, defaults, custom-provider expectations, timeout errors, and cautions around retrying timed-out mutations.
TestsCover timeout validation, cancellation and body deadlines in the shared utility, and verify timeout behavior and configuration across the REST providers.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
55 files changed ·
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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>
Linked issuesChecked at commit 643a480 #599 feat: time out requests of the REST providers · 4 of 4 met
|
There was a problem hiding this comment.
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
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>
|
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 It's the only request that uploads user files, so a 30 s total deadline behaves differently there:
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 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. |
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.
@elixir-cloud/design/utils, next to the problem details utilities, which registers no components):fetchWithTimeout(input, init?, timeout?)aborts the request with aRequestTimeoutError(Request timed out after <n> ms, withtimeout) once the deadline expires; the deadline also covers reading the body. The timer isunrefed in Node, the listener on a caller signal is removed when the deadline expires, and a plainAbortErrorfromfetchmaps to the timeout error. Asignalof the caller (ininitor of aRequest) still aborts with its own reason.resolveRequestTimeout(options)reads{ timeout?: number }(defaultDEFAULT_REQUEST_TIMEOUT= 30 s,0for none;RangeErrorunless an integer from 0 to 2^31 - 1, as longer timers fire at once).RestServiceRegistryProvider,RestCloudRegistryProvider,RestTesProvider,RestWesProvider,RestTrsProvider,RestTrsFilerProvider,RestDrsProvider,RestDrsFilerProvidertakeoptionsas a second constructor argument, exposetimeout, and send requests through the helper in their existingfetch()hook. Subclasses that overridefetch()and callsuper.fetch()(the documented auth pattern) keep the deadline. Components that build their provider frombaseUrlget the default.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.Only the providers' requests are covered: direct
fetchcalls in components (TRS tool files, WES run log files) are not provider requests and keep their behaviour.For anuragxxd
Choices to confirm or change:
@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.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.timeoutis a constructor option (new RestTrsProvider(url, { timeout: 10_000 })), not a component attribute; components withbaseUrluse 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-commitnpm run lintpassed on every commit;prettier --checkon the changed files.GlobalStyles > code editor theme > draws fold arrowsin local Chromium (unchanged code);request-timeout19 passed in both browsers after the review fixes0, caller signal andRequestsignal, validation); each provider (default, invalid timeout, read and write calls reject withRequestTimeoutError,super.fetch()override keeps the deadline and its headers,0sends 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.testscript), 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:
neverAnswerfetch 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.ecc-runs-changedevent: the TES runs component doesn't fire it on any failure today; changing that is component behaviour outside this issue.@elixir-cloud/designdependency (*):scripts/release.js pinpins the@elixir-cloud/*dependencies to the released version at release time.fetchcalls in components (WES run logs, TRS tool files): not provider requests; outside this issue.fetchwith 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 stubbedAbortControllerinstead.Sourcery (threads answered and resolved): fixed the retry example (no retry of timed-out writes), cross-realm
Requestsignals,signal: nulloverriding aRequestsignal, and releasing timer and listener whenfetchrejects. 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 plainAbortErrorback to the caller's reason in browsers without abort reasons: that reason is already lost there, as with nativefetch; (3) the TRS tool component showing "No files available" on anygetToolFiles()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:
Bug Fixes:
Enhancements:
Documentation:
Tests:
Chores: