Skip to content

[Bug]: Windows Google OAuth callback succeeds but cloud session exchange fails with TypeError: fetch failed #10758

Open

Description

@isdead

Operating system

Windows 11 x64

Orca version

v1.4.156 (also reproduced on v1.4.150)

Details

Short summary

Signing in to an Orca Cloud profile with Google completes in the system browser and successfully returns to Orca's local loopback callback, but the desktop then shows:

fetch failed

The cloud profile is never linked and no encrypted account session is created. Updating from v1.4.150 to the current stable v1.4.156 did not change the behavior.

Reproduction

  1. Start Orca on Windows.
  2. Attempt to connect the active local profile to Orca Cloud.
  3. Complete Google sign-in in the system browser.
  4. The browser reaches Orca's 127.0.0.1 callback successfully and displays the successful-return page.
  5. Return to Orca.
  6. Orca reports fetch failed; the active profile remains local.

Expected behavior

After the loopback OAuth callback succeeds, Orca should exchange the authorization code for a cloud session, persist the encrypted session, and link the active profile.

Actual behavior

The post-callback session exchange fails with a bare TypeError: fetch failed. The UI does not expose an error cause or HTTP status, and the failure is not recorded with useful detail in main.trace.ndjson or daemon.log.

Diagnostics already performed

  • Orca runtime is healthy and reachable.

  • The browser successfully reaches Orca's loopback callback, so the local callback listener and OAuth redirect work.

  • login.onorca.dev and relay.onorca.dev resolve and are reachable over HTTPS.

  • A diagnostic Node.js request using the same relevant options to:

    POST https://login.onorca.dev/v1/desktop/auth/session
    

    reaches the service and receives the expected response for a deliberately invalid code:

    401 Unauthorized
    {"error":"invalid_code"}
  • No HTTP(S) proxy environment variables are configured.

  • WinHTTP is configured for direct access.

  • Windows Firewall has no outbound block rule for Orca; default outbound traffic is allowed.

  • Only Windows Defender is active; no third-party antivirus/network filter was detected.

  • Windows Time is synchronized via time.windows.com; an HTTP Date comparison showed approximately 0.5 seconds of skew.

  • The active profile remains kind: "local", has no cloud metadata, and no account-session.json.enc is created.

  • Fully quitting and restarting Orca does not resolve the issue.

This appears to fail after beginOrcaCloudPkceFlow(...) resolves successfully, during the subsequent authorization-code exchange against /v1/desktop/auth/session.

Source correlation

The shipped v1.4.156 main-process bundle still sends this exchange through bare global fetch(...) with redirect: "error" and a 30-second timeout. The surrounding catch path reduces the error to error.message, so users only see fetch failed and the underlying cause (ECONNRESET, TLS, redirect, socket error, etc.) is lost.

A similar transport/pool pattern was reported for another integration in #5593, although this issue affects the first-party Orca Cloud session exchange and reproduces across a full app restart.

Suggested improvements

  1. Log the full error name, stack, and nested error.cause for Orca Cloud session exchange failures, without logging the authorization code, verifier, nonce, state, or tokens.
  2. Surface a bounded failure category in the UI: DNS, TLS, timeout, redirect, connection reset, or HTTP status.
  3. Consider using electron.net.fetch for this first-party request, or retry once on recognized transient Undici transport failures with a fresh connection/dispatcher.
  4. If the backend closes the connection only for otherwise-valid authorization codes, return a structured HTTP error instead so the client does not collapse it into fetch failed.

Related but distinct reports

This report fails earlier, while creating the initial Orca Cloud session.

Made with Orca 🐋

Activity

  1. AmethystLiang commented on Jul 26, 2026

    @AmethystLiang
    Contributor

    thanks for reporting it. looking into it!

  2. added
    bug
    on Jul 27, 2026
  3. nwparker commented on Jul 27, 2026

    @nwparker
    Contributor

    Repro status: skipped (environment blocked)

    Windows Google OAuth callback / cloud session exchange. Requires Windows desktop packaging + live OAuth.

    Not labeling cannot_repro — needs the blocked environment to attempt a full repro.

  4. OrcaWin commented on Aug 16, 2026

    @OrcaWin
    Collaborator

    #14865 (v1.4.183, Windows) reproduced the same OAuth-callback-succeeds / profile-linking fetch failed path and was closed as a duplicate of this issue.

  5. Minidoracat commented on Aug 17, 2026

    @Minidoracat
    Contributor

    Root cause found: Electron's bundled CA list is missing the root that login.onorca.dev chains to — no TLS interception required

    Reproduced on Windows 11 x64, Orca 1.4.184 (also present on 1.4.183), on an ordinary
    residential network with no proxy, no VPN tunnel in use, no corporate TLS inspection, and a
    genuine, unmodified Google certificate chain.

    I instrumented the running main process (Node inspector via process._debugProcess, then wrapped
    globalThis.fetch) to recover the cause that profile-cloud-service.ts discards. That is the
    whole bug's blast radius: the reason was there the entire time, and nothing surfaced it.

    The captured cause

    {
      "url": "https://login.onorca.dev/health",
      "chain": [
        { "name": "TypeError", "message": "fetch failed" },
        { "name": "Error",
          "code": "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
          "message": "unable to verify the first certificate; if the root CA is installed locally, try running Node.js with --use-system-ca" }
      ]
    }

    Why it fails

    login.onorca.dev is Google-hosted. The chain it presents terminates at the cross-signed path:

    CN=login.onorca.dev
      <- CN=WR3, O=Google Trust Services, C=US
        <- CN=GTS Root R1, O=Google Trust Services LLC, C=US
          <- CN=GlobalSign Root CA, OU=Root CA, O=GlobalSign nv-sa, C=BE
    

    That final root, GlobalSign Root CA (OU=Root CA), is present in the Windows system trust store
    but absent from the CA list Electron 43 bundles
    . Node does not consult the OS store, so OpenSSL
    cannot complete the chain.

    Measurements

    tls.getCACertificates(kind).length, same machine, same moment:

    Process bundled default GET login.onorca.dev/health
    Orca 1.4.184 main process (Electron 43.1.0 / Node 24.18.0) 120 120 FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE
    Same binary, ELECTRON_RUN_AS_NODE=1 120 262 (bundled + system) OK 200
    System Node 22.18.0 150 150 OK 200

    Two independent contributors to the failure:

    1. Electron 43 bundles only 120 roots and omits GlobalSign Root CA (OU=Root CA). Node 22's
      150-root list contains it, which is why a plain node process on the same machine succeeds and
      masks the problem during triage.
    2. The browser (main) process does not merge the system store, while ELECTRON_RUN_AS_NODE does.
      This is why testing the "same binary" from a shell does not reproduce it — a trap worth noting
      for anyone attempting a repro.

    Live A/B inside the running main process

    Nothing else changed between the two probes:

    before:  tls.getCACertificates('default').length === 120  ->  FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE
             tls.setDefaultCACertificates(bundled.concat(system))
    after:   tls.getCACertificates('default').length === 162  ->  OK HTTP 200
    

    With the merged store in place, the real sign-in completed immediately:

    POST https://login.onorca.dev/v1/desktop/auth/session  ->  HTTP 200
    

    The profile flipped from kind: "local" to kind: "cloud-linked" and the encrypted session
    artifact was written. Before the patch, that same POST had failed on every attempt across several
    app restarts and two releases.

    This is broader than sign-in

    The same instrumentation caught an unrelated first-party request failing identically in the same
    session:

    GET https://chatgpt.com/backend-api/wham/usage  ->  UNABLE_TO_VERIFY_LEAF_SIGNATURE
    

    Any Node-side fetch in the main process to a host whose chain terminates outside Electron's
    120-root list fails the same way, and — like sign-in — reports nothing usable.

    What this adds to the existing reports

    Reproduction without a live OAuth flow

    No sign-in needed — one request is enough:

    // Run inside the packaged Electron main process (not ELECTRON_RUN_AS_NODE, which merges the
    // system store and hides the bug).
    const tls = require('tls');
    console.log(tls.getCACertificates('default').length);   // 120 on the affected build
    await fetch('https://login.onorca.dev/health');          // TypeError: fetch failed
                                                             // cause.code UNABLE_TO_VERIFY_LEAF_SIGNATURE

    Suggested handling

    1. Land fix(orca-cloud): report the real cause when cloud sign-in cannot reach the network #10789 — it addresses both the transport and the lost cause.
    2. Consider --use-system-ca / tls.setDefaultCACertificates() for anything remaining on Node's
      stack, so the ws Relay control socket is covered too.
    3. Regardless of transport choice, surface error.cause.code in the failure toast. Every hour spent
      on this issue was spent recovering a string the process already had.
  6. Minidoracat commented on Aug 25, 2026

    @Minidoracat
    Contributor

    Correction to my earlier analysis, plus the actual trigger and fix status

    On 2026-08-17 I posted a root cause here naming Electron's bundled CA list omitting GlobalSign Root CA (OU=Root CA) as the reason the chain could not be completed. The mechanism was right; that specific attribution was wrong. Correcting it before it misleads anyone triaging this.

    What is actually happening

    Re-measured today on Windows 11 x64, Orca 1.4.188 (Electron 43.1.0 / Node 24.18.0), ordinary residential network, no proxy and no VPN configured.

    The failing process never sees the upstream chain. A locally installed HTTPS-filtering tool re-signs the connection, and the chain the Orca main process receives terminates at that tool's own root — trusted by Windows, absent from Electron's bundled list. That is the root that cannot be verified.

    The clincher is that the interception is per-application:

    Process — same host, same minute, same network Chain it received Result on bundled roots only
    Orca main process re-signed by the local filtering tool FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE
    a plain electron.exe, Electron 43.1.0 genuine upstream chain HTTP 400 — succeeds

    So the unmodified upstream chain validates fine against Electron's 120 bundled roots: GTS Root R1 is in that list and OpenSSL stops there, never needing the cross-signed GlobalSign Root CA below it. My earlier table correctly showed that root missing from the bundle, but it was not what broke the handshake. I had read the chain from a process that was not being intercepted while the failure was occurring in one that was.

    Why this matters for triage

    • This report's repro was marked skipped (environment blocked). It needs no special environment — only a host where something intercepts the affected application specifically.
    • "The same flow works on my other desktop" ([Bug]: [Windows] OAuth callback succeeds, but profile linking fails with bare "fetch failed" on Orca 1.4.183 #14865) is consistent with per-application filtering rather than a network-wide difference.
    • [Bug]: Cloud sign-in and Orca Relay fail silently behind TLS-inspecting corporate networks #13735 frames this as corporate TLS inspection, and I previously argued that framing was too narrow. It is closer than I credited — the transport really is intercepted — but the practical trap stands: asking users whether they are behind a MITM proxy will incorrectly rule out affected users, because from their side there is no proxy, no VPN and no corporate network. The useful question is what is installed locally.
    • The invariant across every variant of this report is unchanged: Electron's main process does not consult the OS trust store, and profile-cloud-service.ts discards error.cause. Any host whose chain terminates outside the bundled list hits it, and every distinct transport failure arrives as the same three words.

    Fix status

    I rebased #15208 onto current main and opened it as #16399 (authorship preserved), resolving the conflict and a max-lines collision that makes the naive both-hunks resolution fail lint. It carries a before/after matrix measured inside the intercepted Electron main process, with a negative control to isolate the trust store, and the Relay WSS half that #13735 doubted was covered:

    BEFORE  bare globalThis.fetch (ships in 1.4.188) => FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE
    CONTROL undici, bundled roots only               => FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE
    AFTER   undici + first-party trust (Node)        => HTTP 400
    AFTER   firstPartyFetch() (Electron net)         => HTTP 400
    
    BEFORE  bare ws (ships in 1.4.188)               => FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE
    AFTER   first-party relay control socket         => TLS OK
    AFTER   first-party relay data socket            => TLS OK
    

    HTTP 400 is the endpoint's structured rejection of a deliberately invalid authorization code — a complete handshake plus round-trip. No credentials were used.

    Two gaps that fix does not close:

    1. profile-cloud-service.ts still collapses failures to error.message in three places, so the next transport failure of any kind still reads as a bare fetch failed. That half of fix(orca-cloud): report the real cause when cloud sign-in cannot reach the network #10789 is not superseded by fix(cloud): preserve OS trust and network policy for first-party traffic #16399 and is worth landing on its own.
    2. global-fetch-call-site-audit.test.ts still lists main/rate-limits/codex-fetcher.ts (3 sites) among bare-fetch users. On the same host those usage requests fail identically and silently degrade the usage badges.

    Workaround until a fix ships

    Nothing needs to be disabled and no verification needs to be weakened. Pointing NODE_EXTRA_CA_CERTS at a PEM file containing the locally trusted root is sufficient, because Node merges it into the default store at startup. Verified on the affected host: the same request goes from UNABLE_TO_VERIFY_LEAF_SIGNATURE to HTTP 200, and sign-in then completes.

  7. isdead commented on Sep 14, 2026

    @isdead
    Author

    Confirmed local trigger on Windows / Orca 1.4.200: MetaMask interception + AdGuard

    I retested this on Windows 11 x64 with Orca 1.4.200 and was finally able to make Cloud profile linking and Orca Relay work.

    There were two independent layers of failure:

    1. MetaMask browser extension interception

      • Navigating to auth.onorca.dev was redirected to MetaMask's hosted phishing-warning page at metamask.github.io/phishing-warning/.
      • Removing the MetaMask extension stopped that redirect.
      • Orca may want to check whether auth.onorca.dev is on MetaMask's phishing list and request correction/allowlisting if appropriate.
    2. AdGuard process/network filtering

      • After removing MetaMask, browser OAuth completed normally and the loopback callback displayed the successful Orca sign-in page.
      • Orca still showed "Failed to connect profile - fetch failed", and the profile remained local.
      • Turning AdGuard off resolved the failure. The Orca profile linked successfully and Relay became usable.

    Additional observations:

    • login.onorca.dev and relay.onorca.dev resolved and were reachable from the same machine.
    • A direct Node/curl POST to /v1/desktop/auth/session reached the service and returned the expected structured 400 for an empty request.
    • AdGuard's personal root CA is installed in the Windows Current User and Local Machine trust stores.
    • This is consistent with the per-application HTTPS filtering / split trust-store behavior described above: the browser and ordinary system clients succeed, while Orca's main-process Node transport can fail with only the collapsed "fetch failed" message.

    This provides a concrete end-user reproduction supporting #16399 for both Cloud HTTP and Relay WSS, and #10789 for preserving/surfacing the underlying error.cause.

    It would also be useful for Orca to:

    • surface the nested DNS/TLS/proxy/socket error instead of only "fetch failed";
    • honor Windows trust/network policy for first-party Cloud and Relay traffic;
    • document HTTPS-filtering products such as AdGuard as a troubleshooting check until the transport fix ships;
    • avoid recommending that users disable certificate verification globally.

    No OAuth code, token, or callback state is included here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions