Skip to content

globalThis.fetch (undici) does not honor HTTP_PROXY/HTTPS_PROXY env vars #62181

@mjamiv

Description

@mjamiv

Bug Report

Version

  • OpenClaw: 2026.4.5
  • Node: v22 (inside OpenShell sandbox)
  • undici: bundled with Node

Description

globalThis.fetch (powered by undici) does not route through HTTP_PROXY/HTTPS_PROXY by default. This means any code path that uses globalThis.fetch or undici's fetch() directly bypasses the proxy entirely.

In proxy-only environments (like OpenShell sandboxes where all traffic must go through an HTTP CONNECT proxy at 10.200.0.1:3128), this causes LLM provider requests to fail silently or with connection errors — the requests attempt direct connections that the network namespace blocks.

Affected Code Paths

Workaround

At Node.js startup (via NODE_OPTIONS=--require), manually set the global dispatcher:

const { EnvHttpProxyAgent, setGlobalDispatcher } = require('undici');
if (process.env.HTTPS_PROXY || process.env.HTTP_PROXY) {
  setGlobalDispatcher(new EnvHttpProxyAgent());
}

This makes all globalThis.fetch calls honor proxy env vars. We've been running this in production across 4 OpenShell sandboxes since 2026.4.5.

Expected Behavior

When HTTP_PROXY/HTTPS_PROXY are set, OpenClaw should configure undici's global dispatcher to use EnvHttpProxyAgent so that all fetch-based requests route through the proxy — matching the behavior of Node's http/https modules.

Environment

  • OpenShell sandbox with HTTP CONNECT proxy (no direct internet, no DNS)
  • HTTP_PROXY=http://10.200.0.1:3128 and HTTPS_PROXY=http://10.200.0.1:3128 exported

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions