Skip to content

Proxy error on webview open: race condition with dev server startup #321

@7tg

Description

@7tg

Description

When running plannotator review (or plannotator annotate) over SSH Remote, the VSCode webview opens with a "proxy error" because the cookie proxy attempts to connect to the upstream dev server before it's fully listening.

Steps to Reproduce

  1. Connect to a remote machine via VSCode SSH Remote
  2. Run plannotator review from an integrated terminal (or via Claude Code skill)
  3. The plan builds, the dev server starts, and open-in-vscode triggers the webview
  4. The webview panel opens but shows "proxy error"

Expected Behavior

The webview should load the plannotator UI without errors.

Actual Behavior

The cookie proxy in the extension (cookie-proxy.ts) forwards the request to the upstream dev server, but the server isn't ready yet. The proxyReq.on("error") handler fires and returns a 502 with "proxy error".

Workaround: Reloading the webview via Developer: Reload Webviews or re-opening via Plannotator: Open URL in Editor works once the dev server is up.

Root Cause

In extension.cjs, openInPanel immediately creates the proxy and opens the webview as soon as the IPC server receives the URL. However, the plannotator CLI calls openBrowser(url) right after starting the dev server — there's no guarantee the server is accepting connections by the time the proxy forwards the first request.

Suggested Fix

Add a short retry/backoff in the cookie proxy when the upstream connection fails, e.g.:

  • Retry the upstream request 2-3 times with a small delay (200-500ms) before returning 502
  • Or have the webview auto-reload after a brief delay if it receives a proxy error

Environment

  • OS: Linux (Ubuntu, remote via SSH)
  • VSCode: 1.109.2 (SSH Remote)
  • Extension version: 0.5.1
  • plannotator CLI: ELF binary (latest)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions