fix: avoid duplicate stops

This commit is contained in:
7w1 committed 2026-08-06 09:25:03 -05:00
1 parent d74883b7f7
commit fdd427957b
1 file changed
+15 -3
@@ -100,8 +100,13 @@ const startBackgroundClient = async (session: Session): Promise<MatrixClient> =>
timelineLimit: 1,
};
await startClient(mx, startOpts);
return mx;
try {
await startClient(mx, startOpts);
return mx;
} catch (error) {
stopClient(mx);
throw error;
}
};
/**
@@ -302,7 +307,8 @@ export function BackgroundNotifications() {
await waitForSync(mx);
if (disposed || current.get(session.userId) !== mx) {
if (disposed) return;
if (current.get(session.userId) !== mx) {
stopClient(mx);
return;
}
@@ -330,6 +336,12 @@ export function BackgroundNotifications() {
});
}
if (disposed) return;
if (current.get(session.userId) !== mx) {
stopClient(mx);
return;
}
const pushProcessor = mx.pushProcessor;
const handleAccountData = (event: MatrixEvent) => {