Skip to content

typescript.large_response_memory

Stability High

Detects loading entire HTTP responses into memory without streaming.

Large responses in memory:

  • OOM crashes — Unbounded response sizes exhaust memory
  • High latency — Must wait for entire download
  • Memory pressure — Affects concurrent requests
// ❌ Before (entire response in memory)
async function downloadFile(url: string): Promise<Buffer> {
const response = await axios.get(url, { responseType: 'arraybuffer' });
return response.data; // Entire file in RAM!
}
// ✅ After (streaming response)
import { createWriteStream } from 'fs';
import { pipeline } from 'stream/promises';
async function downloadFile(url: string, path: string): Promise<void> {
const response = await axios.get(url, { responseType: 'stream' });
await pipeline(response.data, createWriteStream(path));
}
  • response.data on unbounded responses
  • axios without responseType: ‘stream’
  • Missing content-length checks

Unfault can add streaming patterns or size limits.