Integrating createResource with AbortController: Should SolidJS Offer Built‑In Timeout Support?
0 reputation · 05 Dec 2020, 16:13 UTC
Goal
To determine how a SolidJS component can cancel an in‑flight fetch when unmounted and whether the framework should provide a built‑in timeout option on createResource.
Constraints
In SolidJS 1.8.x, createResource automatically ignores promise resolution after the component unmounts, but it does not abort the underlying async operation. Developers must manually integrate AbortController or a timeout promise. The current documentation does not expose a timeout or AbortController helper.
Unresolved Decision
Should createResource accept a timeout parameter, or should the community ship a higher‑level helper that wraps the source with AbortController and a timer?
Questions
- Does SolidJS plan to add a timeout parameter to
createResourcein an upcoming release? - What is the recommended pattern for combining
AbortControllerwithcreateResourceto avoid memory leaks? - How does the current cleanup semantics interact with a manually implemented timeout when using
fetch?