mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 21:08:17 +00:00
Playwright sends route.fetch(), the request fixture and page.request through one keep-alive agent per worker with no idle timeout, and Node's agent ignores a server's Keep-Alive hint without one. LibreChat and the fixture servers closed idle sockets after 6 s, so a request reusing a socket at that moment was reset (read ECONNRESET) or dropped (socket hang up): the remaining retried passes in wrapping.spec.ts and thread-fold.spec.ts. Run LibreChat with HTTP_KEEP_ALIVE_TIMEOUT_MS=0 and pass every fixture server and the replica proxy through keepIdleConnections(), and check in fixtures.spec.ts that each harness server answers without an idle deadline.
22 lines
1.1 KiB
JavaScript
22 lines
1.1 KiB
JavaScript
/**
|
|
* Leaves idle keep-alive connections open until the client closes them.
|
|
*
|
|
* Playwright sends its Node-side requests (the `request` fixture, `page.request`, `route.fetch`)
|
|
* through one process-wide keep-alive agent with no idle timeout. Node's agent honors a server's
|
|
* `Keep-Alive: timeout=N` hint only by shortening a timeout of its own, so this one keeps an idle
|
|
* socket indefinitely. A Node server, by default, closes an idle socket once `keepAliveTimeout`
|
|
* plus `keepAliveTimeoutBuffer` (6 s) pass; a request that reuses the socket at that moment, or
|
|
* reaches a server too busy to read it before the deadline fires, is reset (`read ECONNRESET`) or
|
|
* dropped (`socket hang up`). Every server the suite drives from Playwright's Node side therefore
|
|
* disables its idle deadline; the backend gets the same through `HTTP_KEEP_ALIVE_TIMEOUT_MS`.
|
|
*
|
|
* @template {import('node:http').Server} T
|
|
* @param {T} server
|
|
* @returns {T}
|
|
*/
|
|
function keepIdleConnections(server) {
|
|
server.keepAliveTimeout = 0;
|
|
return server;
|
|
}
|
|
|
|
module.exports = { keepIdleConnections };
|