Skip to content

typescript.http_missing_timeout

Stability Medium

Detects HTTP client calls without timeout configuration.

HTTP requests without timeouts can hang forever:

  • Stuck requests — Unresponsive servers block your code
  • Resource leaks — Connections held indefinitely
  • User experience — Applications become unresponsive
  • Cascade failures — One slow service blocks everything

Fetch API has no default timeout.

// ❌ Before
const response = await fetch(url);

If the server is slow, this waits forever.

// ✅ After
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30000);
try {
const response = await fetch(url, { signal: controller.signal });
return response;
} finally {
clearTimeout(timeout);
}
  • fetch() without AbortController
  • axios without timeout config
  • HTTP clients missing timeout

Unfault adds AbortController-based timeout.

// Axios - built-in timeout
const response = await axios.get(url, {
timeout: 30000
});
// Got - built-in timeout
const response = await got(url, {
timeout: { request: 30000 }
});
// Helper function
async function fetchWithTimeout(url: string, ms: number) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), ms);
try {
return await fetch(url, { signal: controller.signal });
} finally {
clearTimeout(timeout);
}
}