Skip to content

Limit the wait for a slow or unreachable search service - #2125

Open
jrobinso wants to merge 3 commits into
masterfrom
search-timeout-handling
Open

jrobinso wants to merge 3 commits into
masterfrom
search-timeout-handling

Conversation

@jrobinso

@jrobinso jrobinso commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

A locus search that falls through to the web service waits for it, so a slow or unreachable service delays startup and navigation. This raises the timeout and limits how often it is paid.

Changes

  • Default timeout raised from 2 s to 5 s, and applied to every search service. A custom config.search previously got no timeout at all, so a hung service blocked the search indefinitely. config.search.timeout overrides the default (added to igv.d.ts); 0 turns the timeout off.
  • A service that times out is rested for 60 seconds. Lookups during that time fail without a request, so a multi-term search, or a repeated one, waits for one timeout instead of one per lookup. Only a real timeout rests the service: a request that fails quickly does not, even with status 0, since that can be an error response for a single term blocked by CORS. A service with the timeout turned off is never rested. The timed-out term is not added to the not-found cache, since the failure says nothing about the term.
  • A rested service throws instead of returning "not found", so searchFeatures logs that the service is not available and callers of searchWebService can tell "not searched" from "not found".
  • QTL phenotype gene lookups run four at a time (qtlTrack.js) instead of one after another. All at once would queue requests in the browser long enough to time out. A lookup that fails only loses that gene.
  • Concurrent searches share one load of the search index, which the batched QTL lookups would otherwise trigger several times:
    • TextFeatureSource.search shares the whole-file load of a non-indexed searchable track.
    • BWReader shares the load of a bigBed's search trees, and does not expose them until all are loaded. Before, a search that started while another was loading the trees saw an empty list and returned nothing. That bug predates this PR.

Behaviour to be aware of

  • A custom search service that takes longer than 5 s to respond now times out unless search.timeout is set. This should go in the release notes.
  • While a service is rested, feature-name searches that depend on it find nothing, for up to 60 seconds, even if the service has recovered. The rest is keyed by the service url and shared by all genomes and browsers on the page.
  • With a CORS proxy configured, igv-utils retries a timed-out request through the proxy, so the wait can be twice the timeout. Not changed here.

Testing

New tests:

  • test/testSearch.js: a service that times out is requested once, skipped, and tried again after the rest interval, with a timeout always set; a status-0 failure that returns at once does not rest the service, nor does any failure with the timeout turned off.
  • test/testBigbed.js: four concurrent searches on a fresh bigBed reader all find their feature. This fails without the BWReader change.

The bigBed, search, chrom alias and UCSC suites pass. The QTL change and the shared text-file load have no test, and none of this was tried in a browser.

🤖 Generated with Claude Code

jrobinso and others added 2 commits November 13, 2026 20:26
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

Copilot AI 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.

🟡 Changes recommended

Active issues can omit phenotype genes during concurrent BigBed lookups and incorrectly suspend the search service for 60 seconds after a status-0 failure when timeouts are disabled.

2 open issues
What changed in this PR

This PR limits search-service delays during startup and navigation, while reducing repeated waits and duplicate feature-file loads.

Changes:

  • Applies a configurable 5-second default timeout to search services and pauses retries for 60 seconds after a detected timeout.
  • Batches QTL gene lookups four at a time and shares in-flight loads for non-indexed searchable tracks.
  • Adds tests for service cooldown and immediate status-0 failures.
File Description
test/​testSearch.js Tests timeout cooldown, retry behavior, and immediate failures.
js/​searchFeatures.js Adds the default timeout and service cooldown tracking.
js/​qtl/​qtlTrack.js Batches phenotype gene lookups and isolates lookup failures.
js/​igv.d.ts Declares the optional search timeout setting.
js/​feature/​textFeatureSource.js Shares file loads between concurrent searches.
js/​browser.js Passes the configured timeout to the search service.

Review effort: Balanced

Comment thread js/qtl/qtlTrack.js
const terms = [...genes]
const features = []
for (let i = 0; i < terms.length; i += 4) {
const lookups = terms.slice(i, i + 4).map(term => searchFeatures(this.browser, term).catch(() => undefined))
Comment thread js/searchFeatures.js Outdated
// A timeout says nothing about this term, so the miss is not remembered, the service is rested instead.
// A timeout has status 0, but so does a response blocked by CORS, which can be the answer for a single
// term; the time taken tells them apart.
if (error && error.status === 0 && Date.now() - requestTime >= timeout) {
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

2 participants