feat: add concurrent connection limits

Signed-off-by: hgshreyas <hgshreyas.cs24@bmsce.ac.in>
This commit is contained in:
hgshreyas committed 2026-08-09 17:27:47 +05:30
1 parent 1030109efa
commit 9e5e5cffe9
9 files changed
+28 -3

No files matched your search

+9 -2
View File
@@ -115,15 +115,22 @@ describe('request hardening', () => {
server.close();
});
it('sets the configured server timeouts', async () => {
it('sets the configured server timeouts and connection limit', async () => {
const server = createHttpServer([], [], undefined, undefined,
{ limits: { requestTimeoutMs: 12345, headersTimeoutMs: 6789, keepAliveTimeoutMs: 4321 } });
{ limits: { maxConnections: 2468, requestTimeoutMs: 12345, headersTimeoutMs: 6789, keepAliveTimeoutMs: 4321 } });
expect(server.maxConnections).toBe(2468);
expect(server.requestTimeout).toBe(12345);
expect(server.headersTimeout).toBe(6789);
expect(server.keepAliveTimeout).toBe(4321);
server.close();
});
it('caps concurrent connections by default', () => {
const server = createHttpServer([]);
expect(server.maxConnections).toBe(1000);
server.close();
});
it('requestTimeout does NOT kill an in-flight SSE stream (streaming regression)', async () => {
async function* feed() { for (let n = 1; n <= 3; n++) { yield { n }; await new Promise((r) => setTimeout(r, 80)); } }
const server = createHttpServer(