Skip to content

Default to using app-generated AbortSignal for wrapped fetch#4265

Merged
siosonel merged 4 commits intorelease-2.170from
jira-sv-2774
Mar 4, 2026
Merged

Default to using app-generated AbortSignal for wrapped fetch#4265
siosonel merged 4 commits intorelease-2.170from
jira-sv-2774

Conversation

@siosonel
Copy link
Member

@siosonel siosonel commented Mar 3, 2026

Description

Fixes https://gdc-ctds.atlassian.net/browse/SV-2774 and https://gdc-ctds.atlassian.net/browse/SV-2769.

dofetch3(), when called as a Vocab method, will now set an AbortSignal option if it's missing. Previously, chart data requests already supplied an AbortSignal option. This update supplies an AbortSignal even for non-chart data requests, such as for Correlation Plot variable inputs that query term-specific data, so that the app.dispatch() will not be triggered after such requests. Previously, the detection of stale non-chart data requests was centralized in app.dispatch(), but that assumed that app.dispatch() is triggered before the data request, which may not be true for non-reactive PP components like termsetting and requests like /termdb/descrstats that happen inside termsetting code.

Test:

  • pull sjpp/master
  • follow the steps in SV-2774
  • there should be a cancelled /termdb/descstats request in the Network tab after switching to ALCHEMIST cohort and before the plot data request finishes for TARGET
  • the rendered plot should have 1176 cases for ALCHEMIST and not re-render/change after waiting 30 seconds
Screenshot 2026-03-03 at 5 33 53 PM Screenshot 2026-03-03 at 5 43 15 PM

Checklist

Check each task that has been performed or verified to be not applicable.

  • Tests: Added and/or passed unit and integration tests, or N/A
  • Todos: Commented or documented, or N/A
  • Notable Changes: updated release.txt, prefixed a commit message with "fix:" or "feat:", added to an internal tracking document, or N/A
  • Rust: Checked to see whether Rust needs to be re-compiled because of this PR, or N/A

@siosonel siosonel marked this pull request as ready for review March 3, 2026 23:38
@siosonel siosonel requested review from gavrielm and xzhou82 March 3, 2026 23:38
@siosonel siosonel force-pushed the jira-sv-2774 branch 4 times, most recently from 41e84d5 to 0787040 Compare March 4, 2026 00:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to reduce stale client-side termdb/vocab data requests by ensuring dofetch3() (when invoked as a Vocab/TermdbVocab method) defaults init.signal to an app-generated AbortSignal, so requests can be cancelled on app state changes (e.g. cohort switches).

Changes:

  • Update client/common/dofetch.js:dofetch3() to default init.signal from this.app.getAbortSignal() when called as an object method and the caller didn’t provide a signal.
  • Wire Vocab/TermdbVocab to call dofetch3 as an instance method (this.dofetch3(...)) to enable the above defaulting behavior.
  • Add error-path cache cleanup to memFetch() and update related usage/docs/changelog.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
shared/utils/src/fetch-helpers.js Adds rejection handling in memFetch() to clear cache entries on failed in-flight requests.
server/src/mds3.gdc.js Removes passing q.__abortSignal into a cached /cases memFetch call.
client/termdb/Vocab.js Exposes dofetch3 as an instance method for access to this.app.getAbortSignal().
client/termdb/TermdbVocab.js Switches termdb API calls from dofetch3(...) to this.dofetch3(...).
client/common/dofetch.js Adds defaulting of init.signal based on the caller’s this context; expands comments.
CHANGELOG.md Documents the behavior change in dofetch3() for vocab usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Mar 4, 2026

@siosonel I've opened a new pull request, #4266, to work on those changes. Once the pull request is ready, I'll request review from you.

@siosonel siosonel changed the title Default to using app-generated AbortSignal to wrapped fetch requests Default to using app-generated AbortSignal for wrapped fetch Mar 4, 2026
@siosonel siosonel merged commit f2ce915 into release-2.170 Mar 4, 2026
3 checks passed
@siosonel siosonel deleted the jira-sv-2774 branch March 4, 2026 02:22
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.

4 participants