← Back to PRs

#22252: fix(chrome-extension): connection validation and clarify relay port derivation

by krizpoon open 2026-02-20 23:08 View on GitHub →
docs size: XS
## Problem When users configure a custom gateway port, the Chrome extension requires the **relay port** (gateway + 3), not the gateway port itself. However: 1. The documentation didn't explain the port derivation formula 2. The Options page validation only checked HTTP 200 status, not response content 3. Users got misleading "success" when configuring the gateway port because it returned HTTP 200 with HTML instead of CDP JSON This caused WebSocket connection failures with confusing "pairing required" errors. ## Solution ### 1. Documentation Added "Custom Gateway ports" section to `docs/tools/chrome-extension.md` explaining: - **Extension Relay Port = Gateway Port + 3** - Example: gateway 19001 → relay 19004 ### 2. Validation Fix Updated `assets/chrome-extension/options.js` to: - Validate `Content-Type: application/json` header - Check for CDP response fields (`Browser`, `Protocol-Version`) - Show helpful error with formula when wrong port is configured ## Testing Verified both ports with gateway at 18964: - Port 18964 (gateway): Now shows error "Wrong port: this is the gateway, not the relay. Use gateway port + 3" - Port 18967 (relay): Shows success "Relay reachable and authenticated" ## Example Error Messages **Gateway port (wrong):** ``` Wrong port: this is the gateway, not the relay. Use gateway port + 3 (e.g., if gateway is 18789, use 18792). ``` **Relay port (correct):** ``` Relay reachable and authenticated at http://127.0.0.1:18967/ ``` <!-- greptile_comment --> <h3>Greptile Summary</h3> Enhanced Chrome extension setup by adding port derivation documentation and improving relay endpoint validation. - Added "Custom Gateway ports" section to docs explaining the **relay port = gateway port + 3** formula with examples - Updated `options.js` validation to check `Content-Type: application/json` header and verify CDP response fields (`Browser`, `Protocol-Version`) - Improved error messages to guide users when they mistakenly configure the gateway port (18964) instead of the relay port (18967) - Added error handling to distinguish between JSON parsing errors (wrong endpoint) and connectivity issues <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The changes are well-targeted fixes that improve user experience without modifying core logic. The port derivation formula (gateway + 3) is verified correct by the codebase (`controlPort = gateway + 2`, `relayPort = controlPort + 1`). The validation improvements properly check content-type and response structure, preventing false positives. Error messages are clear and actionable. - No files require special attention <sub>Last reviewed commit: 5295543</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs