openclaw - 💡(How to fix) Fix client.connect() not awaited — failed connection stored in clients map [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#83885Fetched 2026-05-20 03:47:36
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
1
Timeline (top)
labeled ×5commented ×1mentioned ×1subscribed ×1

Error Message

client.connect() is fire-and-forget. The log line says 'Connected' but connection has not been confirmed. More critically, if the initial connection attempt fails with an unrecoverable error (bad credentials, network unreachable) before any reconnect logic kicks in, the client is already stored in this.clients. The next call to getClient for the same account returns the broken client at line 86-87 without retrying setup. disconnectAll will call quit() on it, which is safe, but the window between failed connect and explicit disconnect silently serves a broken client.

Fix Action

Fix / Workaround

Severity: medium / Confidence: medium / Category: bug Triage: risk Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18) Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol


Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID: fnd_sig-feat-cli-command-0c715f7406-_450fcbe91a.

Code Example

client.connect();

    this.clients.set(key, client);
    this.logger.info(`Connected to Twitch as ${account.username}`);
RAW_BUFFERClick to expand / collapse

Severity: medium / Confidence: medium / Category: bug Triage: risk Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18) Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol

Evidence

  • extensions/twitch/src/twitch-client.ts:148-151 (getClient)
client.connect();

    this.clients.set(key, client);
    this.logger.info(`Connected to Twitch as ${account.username}`);

Reasoning

client.connect() is fire-and-forget. The log line says 'Connected' but connection has not been confirmed. More critically, if the initial connection attempt fails with an unrecoverable error (bad credentials, network unreachable) before any reconnect logic kicks in, the client is already stored in this.clients. The next call to getClient for the same account returns the broken client at line 86-87 without retrying setup. disconnectAll will call quit() on it, which is safe, but the window between failed connect and explicit disconnect silently serves a broken client.

Reproduction

Provide invalid credentials so the first connect() fails immediately. Call getClient a second time — it returns the stored broken client without re-attempting auth.

Recommendation

Await client.connect() or add an onAuthenticationFailure/onDisconnect handler that deletes the key from this.clients so a subsequent getClient rebuilds cleanly. At minimum, do not emit the 'Connected' log before the connection resolves.

Why existing tests miss this

Tests mock sendMessageTwitchInternal and never exercise the actual ChatClient.connect() path. The lifecycle tests mock monitorTwitchProvider at a level above getClient.

Suggested regression test

Unit-test getClient with a ChatClient mock whose connect() rejects; assert this.clients does not retain the entry and a second getClient call attempts fresh setup.

Minimum fix scope

Delete the entry from this.clients in an onDisconnect/onAuthFail handler registered before connect(), or await connect() and delete the entry on failure.


Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID: fnd_sig-feat-cli-command-0c715f7406-_450fcbe91a.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix client.connect() not awaited — failed connection stored in clients map [1 comments, 2 participants]