Address PR review feedback by preserving Authorization when fetch init fields are merged into the Discord gateway metadata request and by treating response body read failures as transient wrapped fetch failures. Add a regression test for body stream errors during metadata fetch.
Regeneration-Prompt: |
Follow up on a Discord gateway startup hardening PR after bot review comments. The code already normalizes plain-text Discord /gateway/bot failures, but two edge cases remained: spreading fetchInit after headers could let a future caller clobber the Bot Authorization header, and response.text() could throw while streaming the body and bypass the wrapper that marks startup failures as transient.
Keep the fix narrow to the Discord gateway metadata helper and its tests. Preserve existing behavior for successful fetches and existing proxy support, but make sure both request construction and body-read failures stay inside the same wrapped error path so launchd-managed gateways do not exit on these edge cases.
Normalize Discord /gateway/bot startup failures so plain-text upstream 5xx responses do not crash the launchd-managed gateway. Use the same safe fetch path for proxied and non-proxied Discord startup, and expand transient unhandled-rejection detection for the exact upstream-connect error message family.
Regeneration-Prompt: |
Investigate a launchd-managed OpenClaw gateway restart loop tied to Discord startup. Logs show GatewayPlugin.registerClient calling Discord /gateway/bot and crashing when Discord or an upstream proxy returns a plain-text 503 body like "upstream connect error or disconnect/reset before headers", which then bubbles into an unhandled rejection and exits the whole gateway.
Keep the change additive and tightly scoped to Discord gateway startup and rejection classification. Preserve existing proxy support, but stop assuming the gateway metadata response is always JSON or HTTP 200. Treat transport and upstream 5xx failures as transient so Discord can retry without killing the entire gateway process. Add regression tests covering both normal metadata fetches and the plain-text 503 body that previously triggered the restart loop.
* fix(telegram): preserve media download transport policy
* refactor(telegram): thread media transport policy
* fix(telegram): sync fallback media policy
* fix: note telegram media transport fix (#44639)
Process messageData via handleDeltaEvent for both delta and final states
before resolving the turn, so ACP clients no longer drop the last visible
assistant text when the gateway sends the final message body on the
terminal chat event.
Closes#15377
Based on #17615
Co-authored-by: PJ Eby <3527052+pjeby@users.noreply.github.com>