fix(discord): prevent identify race (#68159)

Verified against Carbon 0.16.0 source:
- Client constructor calls plugin.registerClient(this) without awaiting it.
- GatewayPlugin.registerClient publishes client before its awaited metadata fetch.
- identify() silently returns when client is missing.

This patch matches Carbon's ordering in OpenClaw's subclass, avoids a second super.registerClient call if lifecycle connect already opened the socket during metadata loading, and keeps regression coverage for both ws and isConnecting cases.

Local proof:
- pnpm test extensions/discord/src/monitor/provider.proxy.test.ts extensions/discord/src/monitor/gateway-plugin.test.ts
- pnpm lint:tmp:no-raw-channel-fetch
- pnpm check:changed
- pnpm check
- pnpm test

GitHub checks green for 72547825e1.
This commit is contained in:
IVY
2026-04-25 05:39:44 +08:00
committed by GitHub
parent 78b9890ae1
commit 5adf9d2619
4 changed files with 131 additions and 2 deletions

View File

@@ -22,8 +22,8 @@ const allowedRawFetchCallsites = new Set([
bundledPluginCallsite("browser", "src/browser/test-fetch.ts", 27),
bundledPluginCallsite("chutes", "models.ts", 535),
bundledPluginCallsite("chutes", "models.ts", 542),
bundledPluginCallsite("discord", "src/monitor/gateway-plugin.ts", 387),
bundledPluginCallsite("discord", "src/monitor/gateway-plugin.ts", 453),
bundledPluginCallsite("discord", "src/monitor/gateway-plugin.ts", 417),
bundledPluginCallsite("discord", "src/monitor/gateway-plugin.ts", 483),
bundledPluginCallsite("discord", "src/voice-message.ts", 298),
bundledPluginCallsite("discord", "src/voice-message.ts", 333),
bundledPluginCallsite("elevenlabs", "speech-provider.ts", 295),