mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 21:34:32 +00:00
fix(ci): restore main checks after bulk merges
This commit is contained in:
@@ -119,10 +119,7 @@ export function clearSessionStoreCacheForTest(): void {
|
||||
SESSION_STORE_CACHE.clear();
|
||||
for (const queue of LOCK_QUEUES.values()) {
|
||||
for (const task of queue.pending) {
|
||||
task.timedOut = true;
|
||||
if (task.timer) {
|
||||
clearTimeout(task.timer);
|
||||
}
|
||||
task.reject(new Error("session store queue cleared for test"));
|
||||
}
|
||||
}
|
||||
LOCK_QUEUES.clear();
|
||||
@@ -675,11 +672,8 @@ type SessionStoreLockTask = {
|
||||
fn: () => Promise<unknown>;
|
||||
resolve: (value: unknown) => void;
|
||||
reject: (reason: unknown) => void;
|
||||
timeoutAt?: number;
|
||||
timeoutMs?: number;
|
||||
staleMs: number;
|
||||
timer?: ReturnType<typeof setTimeout>;
|
||||
started: boolean;
|
||||
timedOut: boolean;
|
||||
};
|
||||
|
||||
type SessionStoreLockQueue = {
|
||||
@@ -703,13 +697,6 @@ function getOrCreateLockQueue(storePath: string): SessionStoreLockQueue {
|
||||
return created;
|
||||
}
|
||||
|
||||
function removePendingTask(queue: SessionStoreLockQueue, task: SessionStoreLockTask): void {
|
||||
const idx = queue.pending.indexOf(task);
|
||||
if (idx >= 0) {
|
||||
queue.pending.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
async function drainSessionStoreLockQueue(storePath: string): Promise<void> {
|
||||
const queue = LOCK_QUEUES.get(storePath);
|
||||
if (!queue || queue.running) {
|
||||
@@ -719,21 +706,12 @@ async function drainSessionStoreLockQueue(storePath: string): Promise<void> {
|
||||
try {
|
||||
while (queue.pending.length > 0) {
|
||||
const task = queue.pending.shift();
|
||||
if (!task || task.timedOut) {
|
||||
if (!task) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (task.timer) {
|
||||
clearTimeout(task.timer);
|
||||
}
|
||||
task.started = true;
|
||||
|
||||
const remainingTimeoutMs =
|
||||
task.timeoutAt != null
|
||||
? Math.max(0, task.timeoutAt - Date.now())
|
||||
: Number.POSITIVE_INFINITY;
|
||||
if (task.timeoutAt != null && remainingTimeoutMs <= 0) {
|
||||
task.timedOut = true;
|
||||
const remainingTimeoutMs = task.timeoutMs ?? Number.POSITIVE_INFINITY;
|
||||
if (task.timeoutMs != null && remainingTimeoutMs <= 0) {
|
||||
task.reject(lockTimeoutError(storePath));
|
||||
continue;
|
||||
}
|
||||
@@ -789,7 +767,6 @@ async function withSessionStoreLock<T>(
|
||||
void opts.pollIntervalMs;
|
||||
|
||||
const hasTimeout = timeoutMs > 0 && Number.isFinite(timeoutMs);
|
||||
const timeoutAt = hasTimeout ? Date.now() + timeoutMs : undefined;
|
||||
const queue = getOrCreateLockQueue(storePath);
|
||||
|
||||
const promise = new Promise<T>((resolve, reject) => {
|
||||
@@ -797,23 +774,10 @@ async function withSessionStoreLock<T>(
|
||||
fn: async () => await fn(),
|
||||
resolve: (value) => resolve(value as T),
|
||||
reject,
|
||||
timeoutAt,
|
||||
timeoutMs: hasTimeout ? timeoutMs : undefined,
|
||||
staleMs,
|
||||
started: false,
|
||||
timedOut: false,
|
||||
};
|
||||
|
||||
if (hasTimeout) {
|
||||
task.timer = setTimeout(() => {
|
||||
if (task.started || task.timedOut) {
|
||||
return;
|
||||
}
|
||||
task.timedOut = true;
|
||||
removePendingTask(queue, task);
|
||||
reject(lockTimeoutError(storePath));
|
||||
}, timeoutMs);
|
||||
}
|
||||
|
||||
queue.pending.push(task);
|
||||
void drainSessionStoreLockQueue(storePath);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user