fix: align api keepalive with gateway pool

This commit is contained in:
hectorzhao
2026-08-25 17:35:18 +08:00
parent 76e7c8c401
commit 394949f9f6
8 changed files with 64 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
import { configureApiHttpServerTimeouts } from './http-server-timeouts';
describe('configureApiHttpServerTimeouts', () => {
it('keeps the API connection alive longer than the Gateway idle pool', () => {
const server = { keepAliveTimeout: 0, headersTimeout: 0 };
expect(configureApiHttpServerTimeouts(server, {})).toEqual({
keepAliveTimeoutMs: 120_000,
headersTimeoutMs: 125_000,
});
expect(server).toEqual({ keepAliveTimeout: 120_000, headersTimeout: 125_000 });
});
it('keeps headers timeout above a configured keep-alive timeout', () => {
const server = { keepAliveTimeout: 0, headersTimeout: 0 };
expect(configureApiHttpServerTimeouts(server, {
API_HTTP_KEEP_ALIVE_TIMEOUT_MS: '90000',
API_HTTP_HEADERS_TIMEOUT_MS: '1000',
})).toEqual({ keepAliveTimeoutMs: 90_000, headersTimeoutMs: 91_000 });
});
});