Skip to content

fix: use a dispatcher set with setGlobalDispatcher for driver downloads - #36

Merged
plum117 merged 2 commits into
webdriverio:mainfrom
plum117:fix/honor-global-dispatcher
Oct 9, 2026
Merged

plum117 merged 2 commits into
webdriverio:mainfrom
plum117:fix/honor-global-dispatcher

Conversation

@plum117

@plum117 plum117 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Why

The WebdriverIO proxy docs offer two ways to set a proxy: the HTTPS_PROXY / HTTP_PROXY / NO_PROXY variables, or undici's setGlobalDispatcher in wdio.conf.js ("Option 2", for custom authentication and similar). WebdriverIO's own requests use a custom global dispatcher.

edgedriver 7.x and geckodriver 7.x downloaded with Node's built-in fetch, which uses that global dispatcher. After #29, 8.x gives undici's fetch its own EnvHttpProxyAgent, so the global dispatcher is ignored. A user with Option 2 and no proxy variables would download the drivers directly, and in a closed corporate network the download would fail. This change was not released yet.

Checked with a local proxy and setGlobalDispatcher(new ProxyAgent(…)), and no proxy variables:

requests through the proxy requests direct
edgedriver 7.0.0 (npm) 2 0
main 0 2
this PR (global from undici 8.11.2) 2 0
this PR (global from undici 7.30.0, CONNECT tunnel) 2 (tunneled)

Change

  • A global dispatcher that is not undici's default Agent wins (the same check as webdriver's getDispatcher()). Else the EnvHttpProxyAgent reads the proxy variables, as before.
  • The dispatcher is read for each request, not when the module loads: WebdriverIO imports the drivers before it loads wdio.conf.js.
  • READMEs: a global dispatcher wins over the proxy variables. The edgedriver README now gives findEdgePath() as string | undefined (it returns undefined when Edge is not installed).

Test plan

  • New tests/globalDispatcher.test.ts in edgedriver and geckodriver: set a MockAgent with disableNetConnect() after the module loaded. Red on main (the requests reached the real network); green with the fix
  • e2e proxy.e2e.test.ts (proxy variables, local CONNECT proxy): 3 passed
  • Lint, typecheck, unit tests with coverage

🤖 Generated with Claude Code

7.x downloaded with Node's fetch, which uses the global dispatcher, and
the WebdriverIO proxy docs suggest undici's setGlobalDispatcher. 8.x gave
undici's fetch its own EnvHttpProxyAgent, so those downloads skipped the
proxy. A custom global dispatcher now wins; else the proxy variables
apply. It is read per request, because WebdriverIO sets it after the
driver module has loaded.

Also: findEdgePath() returns string | undefined in the edgedriver README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@plum117
plum117 marked this pull request as ready for review October 9, 2026 19:52
@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the updated tests address the earlier coverage gap.

Summary

The PR lets EdgeDriver and GeckoDriver downloads use a custom global dispatcher set after the packages load. Otherwise, downloads keep using proxy environment variables.

  • Edgedriver and Geckodriver use a custom dispatcher for downloads.
  • The Edgedriver guide says findEdgePath() may return no path.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Version or archive request] --> B[Read global dispatcher]
    B --> C{Custom dispatcher?}
    C -->|Yes| D[Use global dispatcher]
    C -->|No| E[Use EnvHttpProxyAgent]
    D --> F[Fetch metadata or archive]
    E --> F
Loading

Reviews (2) · Last reviewed commit: "test: download the driver archive throug..." · Reviewed by Greptile

Comment thread packages/node-geckodriver/tests/globalDispatcher.test.ts Outdated
The tests stopped after the version lookup, so the archive request could
lose the global dispatcher unseen. Each now serves valid metadata and an
archive from a MockAgent with net connect disabled, and download() must
succeed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@plum117
plum117 merged commit d5692e6 into webdriverio:main Oct 9, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant