Skip to content

fix(e2e): ignore Chromium background CONNECTs in the certificate probe - #1933

Merged
vastsa merged 2 commits into
vastsa:mainfrom
algerkong:fix/certificate-probe-background-connects
Oct 28, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
algerkong:fix/certificate-probe-background-connects

Conversation

@algerkong

Copy link
Copy Markdown
Contributor

Problem

Trusted extensions Electron E2E → Run provider optional client certificate E2E is red on main, so every open PR inherits the failure:

ref trusted-e2e
main 467bc51 failure
main 49430ab failure
main c9e6f05 failure
main f34d36a failure

The fixture proxy asserted that every tunnel it sees targets the fixture:

proxy.on("connect", (req, client, head) => {
  assert.equal(req.headers["proxy-authorization"], ...);
  const target = new URL(`http://${req.url}`);
  assert.equal(target.hostname, "localhost");   // <- fired on background traffic

Chromium's own component updater also reaches the configured session proxy. On a cold CI profile one of those CONNECTs targets a gvt1.com CDN host (rr1---sn-2ovgq5-5m.gvt1.com in the failing run) at an unrelated moment, so the assertion fired through the probe's uncaught-exception path even though every probe step had already logged green. The runner's own traffic is not the request under test.

Change

  • A CONNECT for any host but the fixture is refused with 502 Bad Gateway and never counted, so tunnels keeps measuring fixture traffic only. The proxy-authorization assertion moves after that check, so background traffic cannot trip it either.
  • A self-check drives that refusal explicitly: a synthetic CONNECT rr2.example.invalid:443 must return 502 and leave tunnels at 0, instead of relying on the runner staying quiet.

The probe's own scenarios are untouched.

Verification

  • node scripts/e2e-provider-client-certificate.mjs → provider client certificate E2E passed (Windows, Electron 43, local run).
  • CI evidence that this exact change is what flips the job: the same commit content ran green as 067a13a3 in run 40613349659 (Trusted extensions Electron E2E → success, certificate step success), where main at 467bc51/49430abbd fails the same step.

This is extracted from #1930 (its head commit 067a13a3, same tree, same message) so main can go green on its own: #1932 only inherits the failure and needs this on main to rebase onto.

The probe's proxy asserts that every tunnel it sees targets the fixture, but
Chromium's own component updater reaches the configured session proxy while the
probe is installed. On a cold CI runner that CONNECT arrives at an unrelated
moment — a gvt1.com CDN host in the failing run — and the assertion fired
through the probe's uncaughtException path even though every probe step had
already been logged green.

A CONNECT for any host but the fixture is now refused with 502 and never
counted, so `tunnels` keeps measuring fixture traffic only, and a self-check
asserts that refusal instead of relying on the runner staying quiet.

@muzimu217 muzimu217 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent confirmation of the diagnosis: I reached the same root cause from the run logs before seeing this PR, so the analysis holds from two directions.

The evidence lines up exactly. 49430abbd (00:58Z) failed with actual: 'rr2---sn-2ovgq5-cc.gvt1.com' against expected: 'localhost', and the earlier hang runs (90226c5b4, f34d36a27, c9e6f055a) are plausibly the same defect wearing a different mask: the assertion throws inside the proxy's connect handler, the foreign client is never answered, and Electron's main process does not exit on that uncaught exception, so the probe's pending promise never settles and the harness kills it at 65 s. That also explains why 067a13a30 (01:09Z) went fully green — the job is flaky, not permanently broken, and it only turns red when the component updater happens to fire during the probe.

Two implementation notes, both in this PR's favour:

  • Replying 502 Bad Gateway is better than destroying the socket. Chromium can tell a refused tunnel from a reset, and the probe's own request path never sees an ambiguous EOF.
  • The regression test is the right shape: it drives a real CONNECT rr2.example.invalid:443 through the proxy and asserts both the 502 and tunnels === 0, which pins the two things that were wrong — answering foreign tunnels and counting them. That is stronger than only fixing the handler.

One thing worth adding to the PR body: the hang shape. If the job still fails with provider client certificate E2E hung and was killed by SIGKILL after 65s after this lands, that would mean the hang has a second cause and the assertion fix was necessary but not sufficient. Given the analysis above I expect it to cover both, but naming it makes the next red run easy to classify.

@vastsa
vastsa merged commit b13adfe into vastsa:main Oct 28, 2026
5 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.

3 participants