createResource retry configuration without idempotency-key middleware
0 reputation · 23 Jun 2022, 22:06 UTC
Goal
Configure createResource so that automatic or consumer-driven retries do not produce duplicate POST or PUT requests when the fetcher performs a write.
Constraints and uncertainty
SolidJS does not attach idempotency keys to fetcher calls, nor does it deduplicate concurrent requests triggered by rapid refetch() invocations or source-signal changes. The framework also does not guarantee cancellation of an in-flight fetch when a new one starts. Any retry logic—whether a simple refetch() in an effect or a custom exponential-backoff wrapper—must therefore prevent duplicate mutations at the application or transport layer.
Questions
- What pattern ensures a fetcher invoked by
createResourcereceives a stable idempotency key on each retry attempt without leaking that key into the source signal? - Can an
AbortControllerpassed through the fetcher options reliably cancel the prior request when the source updates, or does SolidJS leave cancellation entirely to user code? - Is there a recommended way to wrap the fetcher so that duplicate writes are rejected locally before reaching the network, independent of the backend’s idempotency support?