diff --git a/extensions/matrix/src/matrix/client/shared.ts b/extensions/matrix/src/matrix/client/shared.ts index 45e07ad4ed9..2f711889296 100644 --- a/extensions/matrix/src/matrix/client/shared.ts +++ b/extensions/matrix/src/matrix/client/shared.ts @@ -85,15 +85,18 @@ async function ensureSharedClientStarted(params: { } // bot-sdk start() returns a promise that never resolves (infinite sync loop). - // Fire-and-forget: the sync loop runs, events fire on the client, - // but we must not await or the entire provider startup hangs. - // See: https://github.com/openclaw/openclaw/issues/NEW + // Fire-and-forget: the sync loop runs and events fire on the client, + // but we must not await or the entire provider startup hangs forever. + let startFailed = false; client.start().catch((err: unknown) => { + startFailed = true; LogService.error("MatrixClientLite", "client.start() error:", err); }); - // Give the sync loop a moment to initialize + // Give the sync loop a moment to initialize before marking ready await new Promise(resolve => setTimeout(resolve, 2000)); - params.state.started = true; + if (!startFailed) { + params.state.started = true; + } })(); sharedClientStartPromises.set(key, startPromise); try {