Timeout or 5xx failure on AngularJS $http POST/PUT/PATCH can duplicate writes on retry
0 reputation · 19 Nov 2022, 14:24 UTC
Context
AngularJS $http provides no built-in retry mechanism, so applications that retry failed POST, PUT, or PATCH requests must implement custom logic. Because these methods are not inherently idempotent, a client-side timeout or 5xx response does not guarantee the server aborted the original write. A subsequent retry can therefore create duplicate records or apply the same mutation twice.
Constraints
The framework reached end of life, so no official updates to $http will add retry counts, idempotency-key headers, or automatic deduplication. Any solution must be built with interceptors, $q chains, or wrapper services that filter by HTTP method and URL. Server-side support for deduplication tokens cannot be assumed.
Open questions
- What pattern ensures a retry is issued only when the original request definitively failed to reach the server?
- How can a client-generated idempotency key be safely attached to unsafe methods without modifying every call site?
- Is there a reliable way to cancel an in-flight $http request so that a retry does not race with the original write?