Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a494d44a2 |
@@ -336,20 +336,29 @@ describe('slow client backpressure (Node)', () => {
|
|||||||
res.pause(); // never read
|
res.pause(); // never read
|
||||||
});
|
});
|
||||||
req.on('error', () => {});
|
req.on('error', () => {});
|
||||||
await new Promise((r) => setTimeout(r, 300));
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
const stalled = flood.produced;
|
const stalled = flood.produced;
|
||||||
await new Promise((r) => setTimeout(r, 300));
|
await sleep(500);
|
||||||
// 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(flood.produced - stalled).toBeLessThanOrEqual(1);
|
||||||
expect(stalled).toBeLessThan(500);
|
expect(stalled).toBeLessThan(2000);
|
||||||
req.destroy();
|
req.destroy();
|
||||||
} finally {
|
} finally {
|
||||||
flood.produced = 0;
|
flood.produced = 0;
|
||||||
await app.close();
|
await app.close();
|
||||||
}
|
}
|
||||||
});
|
}, 20_000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('documented runtime behaviour (Node)', () => {
|
describe('documented runtime behaviour (Node)', () => {
|
||||||
|
|||||||
Reference in new issue
Block a user