Non-idempotent request duplication during $http retry logic
0 reputation · 25 Jun 2020, 14:23 UTC
Request Deduplication in AngularJS $http
AngularJS 1.x does not provide a native mechanism for automatic request retries or built-in deduplication for HTTP calls. When implementing custom retry logic via interceptors or wrapper services, there is a risk of duplicating writes for non-idempotent methods such as POST, PUT, or PATCH if a request fails due to a network timeout after the server has already processed the operation.
Because the $http service does not track request identity or provide a framework-level idempotency key, the responsibility for preventing duplicate data entries falls entirely on the application layer.
Design Constraints
- The framework does not distinguish between safe (GET, HEAD) and unsafe methods during manual retry cycles.
- Interceptors operate on the request/response chain without a native state machine to track previous attempts of the same logical operation.
Should a standardized retry helper default to retrying only safe methods, and if so, what is the recommended pattern for opting into unsafe method retries without disrupting existing interceptor chains?