silx-kit / h5web

React components for data visualization and exploration
https://h5web.panosc.eu/
MIT License
161 stars 17 forks source link

Abort requests with signal via fetch store #1661

Closed axelboc closed 3 weeks ago

axelboc commented 3 weeks ago

We used to set up our own axios CancelToken to cancel value requests but it's deprecated in favour of the web platform's AbortController.

Moreover, in newer versions, react-suspense-fetch creates its own AbortController for each request and passes it on to the store's fetch function. This allows aborting requests (and then evicting them) through the stores instead of having to keep track of ongoing and cancelled requests ourselves in DataProviderApi.

The challenge was that react-suspense-fetch was not providing a way to tell which requests have been aborted in order to evict them from the cache when after the error boundary appears. So I had to tweak things a bit.