mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-09-05 14:08:58 +00:00
* fix(shutdown): disarm the force-exit timer when test state is reset `shutdown()` arms a 60s timer that calls `process.exit(1)` as a safety net for drains that never finish. It is cleared only when the drain runs to completion, so a drain that never settles — an HTTP server whose close callback never fires, a task that hangs — leaves it armed. `__resetShutdownStateForTests()` clears the task list, the shutting-down flag and the server reference, but not that timer. A suite that triggers a signal therefore leaves a live self-destruct behind: `unref` keeps it from holding the process open, but it still fires if anything else keeps the process alive to the timeout, and `process.exit(1)` then takes down whatever is running a minute later. Jest reports that as a bare `process.exit called with "1"` with no failing test, because the run dies before it can print a summary. Track the timer at module scope, clear it from the reset helper, and clear it from a `finally` so a throwing drain step cannot leak it either. The new test fails without the reset change: it starts a drain that never settles, resets state, advances 120s, and asserts the process was not exited. * Scope the force-exit timer to the shutdown that armed it Hoisting the timer to module scope introduced an aliasing hazard: a drain that settles late runs its `finally` against whatever `forceExitTimer` points at by then. If state was reset and a second shutdown armed its own timer in the meantime, the late `finally` cleared the second shutdown's safety net instead of its own. Keep a local handle per shutdown, always clear that, and null the module reference only while it still identifies the same timer. The added test fails without this: it starts a drain whose close callback is withheld, resets state, starts a second shutdown, then releases the first callback and asserts the second net still force-exits. |
||
|---|---|---|
| .. | ||
| src | ||
| types | ||
| .gitignore | ||
| babel.config.cjs | ||
| jest.config.mjs | ||
| jest.setup.cjs | ||
| package.json | ||
| tsconfig-paths-bootstrap.mjs | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
| tsconfig.spec.json | ||
| tsdown.config.mjs | ||