-
Type:
Change Request
-
Resolution: Unresolved
-
Priority:
Trivial
-
None
-
Affects Version/s: 6.0.46, 7.0.26, 7.4.10, 8.0.0alpha2
-
Component/s: Proxy (P), Server (S)
-
None
Hi,
Currently, HttpRequest methods (.get(), .post(), .put(), .delete(), etc.) do not support per-request timeout configuration. All HTTP requests use the global script execution timeout, which can cause issues when:
- A single slow/unresponsive node blocks the entire script execution
- Implementing health check fallback patterns with multiple endpoints
- One HTTP request should fail faster than others within the same script
Desired Behavior
Add an optional third parameter to all HttpRequest methods to specify a per-request timeout (in seconds):
var req = new HttpRequest(); var result = req.get('http://endpoint1/api', null, 5); // 5 second timeout for this request var result = req.post('http://endpoint2/api', data, 3); // 3 second timeout for this request
If no timeout is specified, use the current behavior (5 seconds or remaining global timeout, whichever is smaller).
Use Cases
- Multi-node health checks — Test multiple backend nodes with short timeouts (3-5s), falling back to next node on next execution
- Mixed request patterns — Some requests need longer timeouts, others should fail fast
- Resilience patterns — Implement circuit-breaker style logic by controlling per-request timeout windows
Current Workaround
Implement fallback patterns by cycling through nodes based on execution time (minute modulo), testing one node per script execution to avoid blocking.
var nodes = '{$NODES}'.split(','); var minute = new Date().getMinutes(); var idx = minute % nodes.length; var selectedNode = nodes[idx].trim();try { var req = new HttpRequest(); var result = req.get(selectedNode + '?key=metric'); result; } catch (e) { ''; }