typescript.large_response_memory
Stability
High
Detects loading entire HTTP responses into memory without streaming.
Why It Matters
Section titled “Why It Matters”Large responses in memory:
- OOM crashes — Unbounded response sizes exhaust memory
- High latency — Must wait for entire download
- Memory pressure — Affects concurrent requests
Example
Section titled “Example”// ❌ 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));}What Unfault Detects
Section titled “What Unfault Detects”- response.data on unbounded responses
- axios without responseType: ‘stream’
- Missing content-length checks
Auto-Fix
Section titled “Auto-Fix”Unfault can add streaming patterns or size limits.