Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(e2e): ignore Chromium background CONNECTs in the certificate probe (#1933)
Algerb13adfebcfec
diff --git a/scripts/e2e/provider-client-certificate.ts b/scripts/e2e/provider-client-certificate.tsindex 78fc86bf1..dacc5c279 100644--- a/scripts/e2e/provider-client-certificate.ts+++ b/scripts/e2e/provider-client-certificate.ts@@ -44,9 +44,18 @@ const server = createHttpsServer({ key, cert, ca: cert, requestCert: true, rejecconst proxy = createHttpServer();let tunnels = 0;proxy.on("connect", (req, client, head) => {- assert.equal(req.headers["proxy-authorization"], `Basic ${Buffer.from("fixture:password").toString("base64")}`);const target = new URL(`http://${req.url}`);- assert.equal(target.hostname, "localhost");+ // Chromium's own background fetches (component updater, CRL sets) can reach the+ // session proxy while this probe is installed — a cold profile on a CI runner+ // connects to a gvt1.com CDN host, for one. Anything but the fixture is that+ // traffic, not the request under test: refuse it, and keep both the assertions+ // and `tunnels` about the fixture, so the runner's own traffic cannot fail a+ // probe that never asked for it.+ if (target.hostname !== "localhost") {+ client.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");+ return;+ }+ assert.equal(req.headers["proxy-authorization"], `Basic ${Buffer.from("fixture:password").toString("base64")}`);tunnels++;const upstream = connect({ host: "127.0.0.1", port: Number(target.port) });sockets.add(upstream);@@ -81,6 +90,21 @@ void app.whenReady().then(async () => {const proxyAddress = proxy.address();assert.ok(address && typeof address !== "string" && proxyAddress && typeof proxyAddress !== "string");const baseUrl = `https://localhost:${address.port}/v1`;+ // A CONNECT for any host but the fixture is Chromium's own traffic on a cold+ // profile (component updater, CRL sets) and must be refused, never counted:+ // it used to trip the tunnel assertions on CI runners (see the proxy handler).+ const backgroundRefusal = await new Promise<string>((resolve, reject) => {+ const socket = connect({ host: "127.0.0.1", port: proxyAddress.port });+ let received = "";+ socket.on("error", reject);+ socket.on("connect", () => {+ socket.write("CONNECT rr2.example.invalid:443 HTTP/1.1\r\nHost: rr2.example.invalid:443\r\n\r\n");+ });+ socket.on("data", (chunk) => { received += chunk.toString("latin1"); });+ socket.on("close", () => resolve(received));+ });+ assert.match(backgroundRefusal, /^HTTP\/1\.1 502 Bad Gateway/);+ assert.equal(tunnels, 0, "background CONNECTs must not count as fixture tunnels");await applyNetworkProxy({ mode: "direct" });let baselineTimer: ReturnType<typeof setTimeout> | undefined;const baselineTimeout = new Promise<{ kind: "timeout" }>((resolve) => {