mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 14:08:21 +00:00
* perf: reduce agent chat startup latency * test: align Redis stream readiness assertions * perf: overlap remaining agent startup work * perf: persist initial agent job metadata atomically * test: add agent startup latency benchmark * fix: harden resumable agent stream lifecycle * fix: isolate replacement stream lifecycles * fix: preserve terminal stream epochs
20 lines
667 B
JavaScript
20 lines
667 B
JavaScript
const mongoose = require('mongoose');
|
|
|
|
const delayMs = Number.parseInt(process.env.E2E_LATENCY_MONGO_DELAY_MS ?? '', 10);
|
|
const patched = Symbol.for('librechat.e2e.mongooseLatencyPatched');
|
|
|
|
function patchExec(prototype) {
|
|
if (!Number.isInteger(delayMs) || delayMs <= 0 || prototype[patched]) {
|
|
return;
|
|
}
|
|
|
|
const originalExec = prototype.exec;
|
|
Object.defineProperty(prototype, patched, { value: true });
|
|
prototype.exec = async function delayedExec(...args) {
|
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
return originalExec.apply(this, args);
|
|
};
|
|
}
|
|
|
|
patchExec(mongoose.Query.prototype);
|
|
patchExec(mongoose.Aggregate.prototype);
|