facebook / facebook/relay

Provide an AbortSignal to network functions when possible

Open
#2,414 14 comments 11 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Now that [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) is available in all up-to-date browsers, it would be helpful if relay passed a signal to network functions. This way, when an in-progress query is invalidated (due to variables changing, or the react component being removed from the virtual DOM, etc) we have a way to cancel the request and open up space in the browser's request queue.

For me, this is especially important in a "search-while-typing" interface, where in-flight queries are frequently invalidated by more user input.

While an `AbortController` signal is used by native `fetch`, the spec was designed to be a general purpose mechanism for handling abortable calls, so this is probably a best practice going forward.

Contributor guide

Open the contributing guide

Research direction

Start by tracing Relay's network functions and the lifecycle that invalidates in-progress queries, using the issue's AbortController and native fetch references as the starting points. The work is done when invalidated requests receive an abort signal and cancellation works for changing variables or removed React components, including search-while-typing flows.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
api, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.