ESLint InterlaceESLint Interlace
Plugin: reliabilityRules

require-network-timeout

ESLint rule documentation for require-network-timeout

📡 Live from GitHub — This documentation is fetched directly from require-network-timeout.md and cached for 6 hours.

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.

Require timeout configuration for network requests. This rule is part of eslint-plugin-reliability and provides LLM-optimized error messages with suggestions.

Quick Summary

AspectDetails
SeverityWarning (reliability)
Auto-Fix💡 Suggests fixes
CategoryReliability
ESLint MCP✅ Optimized for ESLint MCP integration
Best ForApplications 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

IssueImpactSolution
⏱️ Hanging RequestsApp freezes waiting foreverSet explicit timeouts
🔄 Resource LeaksConnections never releasedAbort after timeout
👤 User ExperienceUsers wait indefinitelyFail fast with timeout
📊 MonitoringHard to detect slow endpointsTimeout 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 with AbortController timeout
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000);

try {
  const response = await fetch('/api/data', {
    signal: controller.signal,
  });
} finally {
  clearTimeout(timeoutId);
}

// axios with timeout
const result = await axios.get('/api/users', {
  timeout: 5000,
});

// Using a timeout utility
async function fetchWithTimeout(url: string, timeout = 5000) {
  const controller = new AbortController();
  const id = setTimeout(() => controller.abort(), timeout);

  try {
    const response = await fetch(url, { signal: controller.signal });
    return response;
  } finally {
    clearTimeout(id);
  }
}

// Global axios configuration
const api = axios.create({
  baseURL: '/api',
  timeout: 10000,
});

Configuration Examples

Basic Usage

{
  rules: {
    'reliability/require-network-timeout': 'warn'
  }
}

Custom Timeout Threshold

{
  rules: {
    'reliability/require-network-timeout': ['warn', {
      minTimeout: 3000,
      maxTimeout: 30000
    }]
  }
}

Further Reading

On this page

No Headings