Follow-up · depth 1
How would you test Streams and Backpressure?
How would you test Streams and Backpressure?
Answers use simple, clear English.
Quick interview answer
Test Streams and Backpressure with unit checks for the happy path, integration tests for real I/O boundaries, and load/chaos checks so regressions show up before prod. Core idea: Baseline: Readable pushes data; Writable signals backpressure when internal buffer exceeds highWaterMark. Respect drain event before resuming writes to avoid memory blowup.
Detailed answer
Interview answer for testing Streams and Backpressure: 1) Unit: isolate the pure logic behind Streams and Backpressure with deterministic fixtures. 2) Integration: exercise real timers/I/O/network boundaries the way production does. 3) Load & soak: prove the event path still meets SLOs under concurrency. 4) Failure injection: break dependencies and assert recovery/backpressure. Best practices to include: Use pipeline() from stream/promises for automatic cleanup on error. Call out mistakes: Ignoring write() return false; not awaiting 'drain' on backpressure. Parent context: Baseline: Readable pushes data; Writable signals backpressure when internal buffer exceeds highWaterMark. Respect drain event before resuming writes to avoid memory blowup.
Full explanation
Interviewers want a test strategy, not “I would write tests.” Tie each layer back to how Streams and Backpressure fails: correctness, latency, and starvation. Readable pushes data; Writable signals backpressure when internal buffer exceeds highWaterMark. Respect drain event before resuming writes to avoid memory blowup.
Follow-up questions
Only answered follow-ups are shown — click to open with full answers
Parent context — Streams and Backpressure
Baseline: Readable pushes data; Writable signals backpressure when internal buffer exceeds highWaterMark. Respect drain event before resuming writes to avoid memory blowup.
View full parent question →