Plugin: reliabilityRules
require-network-timeout
Require timeout configuration for network requests. This rule is part of eslint-plugin-reliability and provides LLM-optimized error messages.
Keywords: network, timeout, fetch, http, ESLint rule, reliability, performance, LLM-optimized
Require timeout configuration for network requests. This rule is part of eslint-plugin-reliability and provides LLM-optimized error messages with suggestions.
Quick Summary
| Aspect | Details |
|---|---|
| Severity | Warning (reliability) |
| Auto-Fix | 💡 Suggests fixes |
| Category | Reliability |
| ESLint MCP | ✅ Optimized for ESLint MCP integration |
| Best For | Applications making HTTP requests |
Rule Details
This rule ensures that all network requests include timeout configuration to prevent hanging connections and improve application reliability.
Why This Matters
| Issue | Impact | Solution |
|---|---|---|
| ⏱️ Hanging Requests | App freezes waiting forever | Set explicit timeouts |
| 🔄 Resource Leaks | Connections never released | Abort after timeout |
| 👤 User Experience | Users wait indefinitely | Fail fast with timeout |
| 📊 Monitoring | Hard to detect slow endpoints | Timeout helps identify |
Examples
❌ Incorrect
// fetch without timeout
const response = await fetch('/api/data');
// axios without timeout
const result = await axios.get('/api/users');
// HTTP client without timeout config
const data = await httpClient.request({ url: '/api' });✅ Correct
fetch(url, { timeout: 5000 })Configuration Examples
Basic Usage
{
rules: {
'reliability/require-network-timeout': 'warn'
}
}Custom Timeout Threshold
{
rules: {
'reliability/require-network-timeout': ['warn', {
minTimeout: 3000,
maxTimeout: 30000
}]
}
}Related Rules
no-await-in-loop- Optimize async loopsno-unhandled-promise- Handle async errors
Further Reading
- AbortController - MDN documentation
- Axios Timeout - Axios configuration
- ESLint MCP Setup - Enable AI assistant integration