Question
AngularJS $http Timeout: Diagnosing Unexpected Status -1 Errors
Lax Cedar
0 reputation · 01 Aug 2024, 14:32 UTC
81.3K views0
Goal
Determine why an AngularJS 1.x application’s $http requests are failing with a status of -1 and a statusText of "timeout" even though the server should respond within the configured timeframe.
Constraints & Uncertainty
- The $http service is configured with a numeric timeout in milliseconds, but the actual request duration may vary across browsers and network conditions.
- Server‑side processing time is unknown; the client aborts after the timeout regardless of server completion.
- Network errors can masquerade as timeouts in some environments, complicating error source identification.
Specific Questions
- What mechanisms does AngularJS use internally to trigger and reject the promise when the timeout expires?
- How can one programmatically distinguish a client‑side timeout from a network failure or server‑side timeout when inspecting the error object?
- What best‑practice patterns exist to adjust the timeout dynamically based on the request type or current network latency?