mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
* fix(feishu): route /btw through out-of-band lanes * fix(feishu): bound btw out-of-band lanes * fix: route feishu btw out-of-band (#64324) (thanks @ngutman)
16 lines
430 B
TypeScript
16 lines
430 B
TypeScript
export function createSequentialQueue() {
|
|
const queues = new Map<string, Promise<void>>();
|
|
|
|
return (key: string, task: () => Promise<void>): Promise<void> => {
|
|
const previous = queues.get(key) ?? Promise.resolve();
|
|
const next = previous.then(task, task);
|
|
queues.set(key, next);
|
|
void next.finally(() => {
|
|
if (queues.get(key) === next) {
|
|
queues.delete(key);
|
|
}
|
|
});
|
|
return next;
|
|
};
|
|
}
|