Skip to content

✨ Percy doctor#2118

Merged
ninadbstack merged 29 commits intomasterfrom
percy-doctor
Mar 16, 2026
Merged

✨ Percy doctor#2118
ninadbstack merged 29 commits intomasterfrom
percy-doctor

Conversation

@rishigupta1599
Copy link
Copy Markdown
Contributor

@rishigupta1599 rishigupta1599 commented Feb 26, 2026

Percy Doctor – Network Diagnostics Command (@percy/cli-doctor)

Summary

Introduces a brand-new @percy/cli-doctor package that adds percy doctor to the Percy CLI. The command diagnoses network connectivity, TLS/SSL, proxy configuration, PAC/WPAD auto-proxy, and browser-level reachability — giving users and support teams a single, actionable runbook whenever Percy builds fail for network-related reasons.


Why

Percy builds silently fail on enterprise networks due to firewalls, SSL-intercepting proxies (Zscaler, Netskope, Bluecoat), authenticated proxies, and PAC/WPAD auto-proxy misconfiguration. Diagnosing these issues today requires manual curl commands, reading Node TLS error codes, and guessing which proxy env var to set.

percy doctor automates all of this: it probes the required endpoints, detects how traffic is being intercepted, evaluates PAC scripts, and prints a prioritised list of actionable suggestions.


What Changed

1. New package: @percy/cli-doctor

File Purpose
src/doctor.js percy doctor command entry point; JSON report writer (--output-json)
src/index.js Public exports
src/checks/connectivity.js ConnectivityChecker — parallel probe of percy.io, browserstack.com, hub.browserstack.com, storage.googleapis.com (optional)
src/checks/proxy.js ProxyDetector — 5-layer proxy discovery + per-proxy validation via CONNECT tunnel
src/checks/pac.js PACDetector — PAC/WPAD discovery from env, macOS, Linux, Windows, Chrome, Firefox; sandboxed vm evaluation
src/checks/browser.js BrowserChecker — Chrome CDP capture; direct vs. via-proxy comparison table
src/utils/http.js probeUrl / httpProber — CONNECT-tunnelling HTTP prober with configurable timeout and TLS controls
src/utils/helpers.js Orchestration helpers: runConnectivityAndSSL, runProxyCheck, runPACCheck, runBrowserCheck, redactProxyUrl, captureProxyEnv
src/utils/reporter.js Terminal pretty-printer (✔ / ⚠ / ✖ / ℹ symbols, colour, nested suggestions)

2. Five diagnostic checks

# Check Detection layers
1 Network Connectivity Parallel HTTPS probes; HTTP-status-aware pass/fail; proxy fallback path
2 SSL / TLS Derived from connectivity probe (zero extra RTTs); NODE_TLS_REJECT_UNAUTHORIZED warn; actionable cert-error suggestions
3 Proxy Configuration (a) env vars → (b) OS system settings (macOS scutil, Linux GNOME//etc, Windows registry) → (c) response-header fingerprinting (Via, X-Forwarded-For, Zscaler/Netskope headers) → (d) process inspection (50+ known agents) → (e) WPAD DNS auto-discovery
4 PAC / Auto-Proxy macOS networksetup, Linux gsettings//etc/environment, Windows AutoConfigURL, Chrome Default/Preferences, Firefox prefs.js; PAC fetched + evaluated in Node.js vm sandbox; shows exact HTTPS_PROXY= export
5 Browser Network Analysis Spawns Chrome via CDP; captures all requestWillBeSent / responseReceived / loadingFailed events; direct vs. proxy two-column table; --ignore-certificate-errors mirrored from NODE_TLS_REJECT_UNAUTHORIZED

4. JSON report (--output-json)

Full machine-readable diagnostic output including environment metadata (Node version, platform, Percy CLI version, proxy env), per-check findings, and an overall summary field. Designed to be attached to Percy support tickets.

Breaking Changes

None. This PR only adds a new package. No existing packages are modified beyond packages/cli/package.json (to wire in the new command.

@rishigupta1599 rishigupta1599 marked this pull request as ready for review March 13, 2026 11:54
@rishigupta1599 rishigupta1599 requested a review from a team as a code owner March 13, 2026 11:54
@rishigupta1599 rishigupta1599 changed the title Percy doctor ✨ Percy doctor Mar 13, 2026
@ninadbstack ninadbstack merged commit 2860f1c into master Mar 16, 2026
41 of 43 checks passed
@ninadbstack ninadbstack deleted the percy-doctor branch March 16, 2026 07:04
rishigupta1599 added a commit that referenced this pull request Mar 16, 2026
* initial commit

* more changes

* cleaning up few things

* more changes

* Adding specs

* semgrep ignore

* yarn lock with node 14

* adding coverage

* Adding coverage

* adding coverage

* adding coverage

* Removing function injection + more coverage

* More coverage + refactoring

* final coverage

* package version update

* windows test fix

* covering macos cases

* coverage

* coverage

* coverage

* coverage

* coverage

* fixing flay specs

* Removing ssl.js as it is removed

* CodeQL/ semgrep

* semgrep

* Resolving comments from AI researcher

* semgrep resolve

* semgrep ci
@rishigupta1599 rishigupta1599 restored the percy-doctor branch March 16, 2026 11:07
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.

2 participants