Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5643da03a |
@@ -336,29 +336,20 @@ describe('slow client backpressure (Node)', () => {
|
||||
res.pause(); // never read
|
||||
});
|
||||
req.on('error', () => {});
|
||||
// Each frame is ~28 KB of nearly incompressible text. Without backpressure the generator never
|
||||
// stops; with it, it stops once the socket, the response and the compressor's buffers are full.
|
||||
// How many frames that takes depends on the kernel's socket buffers (Linux auto-tunes them to
|
||||
// several MB), so wait for production to stall rather than for a fixed time.
|
||||
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
||||
let previous = -1;
|
||||
|
||||
for (let waited = 0; flood.produced !== previous; waited += 200) {
|
||||
expect(waited, `still producing after ${waited} ms: ${flood.produced} frames`).toBeLessThan(10_000);
|
||||
previous = flood.produced;
|
||||
await sleep(200);
|
||||
}
|
||||
|
||||
await new Promise((r) => setTimeout(r, 300));
|
||||
const stalled = flood.produced;
|
||||
await sleep(500);
|
||||
await new Promise((r) => setTimeout(r, 300));
|
||||
// Each frame is ~28 KB of nearly incompressible text. Without backpressure the generator would
|
||||
// keep running for the whole 600 ms (thousands of frames); with it, it stops once the socket,
|
||||
// the response and the compressor's buffers are full, and does not move afterwards.
|
||||
expect(flood.produced - stalled).toBeLessThanOrEqual(1);
|
||||
expect(stalled).toBeLessThan(2000);
|
||||
expect(stalled).toBeLessThan(500);
|
||||
req.destroy();
|
||||
} finally {
|
||||
flood.produced = 0;
|
||||
await app.close();
|
||||
}
|
||||
}, 20_000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('documented runtime behaviour (Node)', () => {
|
||||
|
||||
Reference in new issue
Block a user