Skip to content

Discord Gateway WebSocket should honor HTTP_PROXY/HTTPS_PROXY env proxy fallback #98266

Description

@svuppala2006

Summary

Discord Gateway WebSocket does not honor HTTP_PROXY/HTTPS_PROXY environment variables, forcing deployments with egress restrictions to allow broad :443 access (security downgrade).

Current Behavior

extensions/discord/src/monitor/gateway-plugin.ts:402 always creates a direct HttpsAgent for WebSocket connections. Environment proxy is only used if channels.discord.proxy is explicitly configured (which requires loopback host).

Expected Behavior

Gateway WebSocket should honor HTTP_PROXY/HTTPS_PROXY env vars as fallback, matching the existing pattern:

  • ✅ Discord REST API: extensions/discord/src/monitor/rest-fetch.ts:35
  • ✅ WhatsApp WebSocket: extensions/whatsapp/src/session.ts:193

Proposed Fix

In gateway-plugin.ts:402, add env proxy fallback before direct HttpsAgent:

const envProxyAgent = createEnvProxyDiscordGatewayAgent(params.runtime);
if (envProxyAgent) {
  wsAgent = envProxyAgent;
} else {
  wsAgent = new HttpsAgent({ lookup: discordDnsLookup });
}

// Explicit channels.discord.proxy still overrides
if (proxy) { /* existing logic */ }

Mirror the helper pattern from rest-fetch.ts:35.

Impact

Blocks Discord channel deployment in Kubernetes/OpenShift with network policy egress restrictions. Currently requires broad :443 egress as workaround.

Related: #60035

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions