mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-21 15:01:03 +00:00
Matrix: avoid shutdown races in decrypt drain
This commit is contained in:
@@ -327,6 +327,9 @@ describe("monitorMatrixProvider", () => {
|
||||
hoisted.client.drainPendingDecryptions.mockImplementation(async () => {
|
||||
hoisted.callOrder.push("drain-decrypts");
|
||||
});
|
||||
hoisted.stopThreadBindingManager.mockImplementation(() => {
|
||||
hoisted.callOrder.push("stop-manager");
|
||||
});
|
||||
hoisted.releaseSharedClientInstance.mockImplementation(async () => {
|
||||
hoisted.callOrder.push("release-client");
|
||||
return true;
|
||||
@@ -365,6 +368,9 @@ describe("monitorMatrixProvider", () => {
|
||||
hoisted.callOrder.indexOf("handler-done"),
|
||||
);
|
||||
expect(hoisted.callOrder.indexOf("handler-done")).toBeLessThan(
|
||||
hoisted.callOrder.indexOf("stop-manager"),
|
||||
);
|
||||
expect(hoisted.callOrder.indexOf("stop-manager")).toBeLessThan(
|
||||
hoisted.callOrder.indexOf("stop-deduper"),
|
||||
);
|
||||
expect(hoisted.callOrder.indexOf("stop-deduper")).toBeLessThan(
|
||||
|
||||
@@ -153,10 +153,10 @@ export async function monitorMatrixProvider(opts: MonitorMatrixOpts = {}): Promi
|
||||
}
|
||||
cleanedUp = true;
|
||||
try {
|
||||
threadBindingManager?.stop();
|
||||
client.stopSyncWithoutPersist();
|
||||
await client.drainPendingDecryptions("matrix monitor shutdown");
|
||||
await waitForInFlightRoomMessages();
|
||||
threadBindingManager?.stop();
|
||||
await inboundDeduper.stop();
|
||||
await releaseSharedClientInstance(client, "persist");
|
||||
} finally {
|
||||
|
||||
@@ -337,6 +337,10 @@ export class MatrixDecryptBridge<TRawEvent extends DecryptBridgeRawEvent> {
|
||||
}
|
||||
await new Promise<void>((resolve) => {
|
||||
this.retryIdleResolvers.add(resolve);
|
||||
if (this.activeRetryRuns === 0) {
|
||||
this.retryIdleResolvers.delete(resolve);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user