The best way to control Claude Code, Codex and more from any computer or phone
fix(shared): relay client install survives antivirus-slowed first launch (#27426)
Julius Marminge committed
Nov 11, 2026 at 15:21 UTC
96a2f0a7763f800e11905f421ad172524ec3b515
2 files changed
+59
-12
packages/shared/src/relayClient.test.ts
+41
@@ -471,6 +471,47 @@ describe("RelayClient", () => {
471
),
472
);
473
474
+ it.effect.skipIf(windowsHost)(
475
+ "installs when the downloaded binary's first launch is held by an antivirus scan",
476
+ () =>
477
+ Effect.gen(function* () {
478
+ const fileSystem = yield* FileSystem.FileSystem;
479
+ const baseDir = yield* fileSystem.makeTempDirectoryScoped({
480
+ prefix: "t3-cloudflared-test-",
481
+ });
482
+ const scanning = yield* Deferred.make<void>();
483
+ const manager = yield* RelayClient.makeCloudflaredRelayClient({
484
+ baseDir,
485
+ releaseAsset: testReleaseAsset,
486
+ }).pipe(
487
+ Effect.provideService(
488
+ ChildProcessSpawner.ChildProcessSpawner,
489
+ ChildProcessSpawner.make(() =>
490
+ Deferred.succeed(scanning, undefined).pipe(
491
+ Effect.andThen(Effect.sleep("25 seconds")),
492
+ Effect.as(
493
+ makeHandle(
494
+ 0,
495
+ `cloudflared version ${RelayClient.CLOUDFLARED_VERSION} (built 2026-01-01-00:00 UTC)\n`,
496
+ ),
497
+ ),
498
+ ),
499
+ ),
500
+ ),
501
+ );
502
+
503
+ const installing = yield* manager.install.pipe(Effect.forkChild);
504
+ yield* Deferred.await(scanning);
505
+ yield* TestClock.adjust("25 seconds");
506
+
507
+ expect(yield* Fiber.join(installing)).toMatchObject({
508
+ status: "available",
509
+ source: "managed",
510
+ version: RelayClient.CLOUDFLARED_VERSION,
511
+ });
512
+ }).pipe(Effect.scoped, Effect.provide(layerInstallRuntime("linux"))),
513
+ );
514
+
515
it.effect("rejects downloads whose checksum does not match the pinned manifest", () =>
516
Effect.gen(function* () {
517
const fileSystem = yield* FileSystem.FileSystem;
packages/shared/src/relayClient.ts
+18
-12
@@ -141,6 +141,8 @@ const INSTALL_LOCK_RETRY_DELAY = "100 millis";
141
// Legacy locks have no owner; allow both ten-minute download stages and the install tail.
142
const INSTALL_LOCK_LEGACY_STALE_MS = 30 * 60 * 1_000;
143
const VERSION_PROBE_TIMEOUT = "10 seconds";
144
+// Antivirus scans can hold the first launch of a freshly downloaded binary for 20-30 s.
145
+const INSTALL_VALIDATION_TIMEOUT = "2 minutes";
146
147
const ACTIVATE_RETRY_COUNT = 40;
148
const ACTIVATE_RETRY_DELAY = "250 millis";
@@ -299,19 +301,23 @@ export const makeCloudflaredRelayClient = Effect.fn("cloudflared.make")(function
301
return platform === "win32" || (info.value.mode & 0o111) !== 0;
302
});
303
304
+ const runVersionProbe = Effect.fn("cloudflared.runVersionProbe")(function* (
305
+ executablePath: string,
306
+ timeout: Duration.Input,
307
+ ) {
308
+ return yield* spawner
309
+ .string(ChildProcess.make(executablePath, ["version"], { stdin: "ignore", stderr: "ignore" }))
310
+ .pipe(
311
+ Effect.map(parseCloudflaredVersionOutput),
312
+ Effect.timeoutOption(timeout),
313
+ Effect.map(Option.getOrNull),
314
+ Effect.orElseSucceed(() => null),
315
+ );
316
+ });
317
+
318
// Cache successful version probes per file revision; do not let transient failures hide valid binaries.
319
const versionCache = yield* Cache.makeWith(
304
- (key: VersionProbeKey) =>
305
- spawner
306
- .string(
307
- ChildProcess.make(key.executablePath, ["version"], { stdin: "ignore", stderr: "ignore" }),
308
- )
309
- .pipe(
310
- Effect.map(parseCloudflaredVersionOutput),
311
- Effect.timeoutOption(VERSION_PROBE_TIMEOUT),
312
- Effect.map(Option.getOrNull),
313
- Effect.orElseSucceed(() => null),
314
- ),
320
+ (key: VersionProbeKey) => runVersionProbe(key.executablePath, VERSION_PROBE_TIMEOUT),
321
{
322
capacity: 16,
323
timeToLive: (exit) =>
@@ -648,7 +654,7 @@ export const makeCloudflaredRelayClient = Effect.fn("cloudflared.make")(function
654
}
655
yield* report("validating");
656
// Verify the pin so mislabeled assets cannot cause repeated redownloads.
651
- const installedVersion = yield* probeVersion(executablePath);
657
+ const installedVersion = yield* runVersionProbe(executablePath, INSTALL_VALIDATION_TIMEOUT);
658
if (installedVersion !== CLOUDFLARED_VERSION) {
659
return yield* new RelayClientInstallError({
660
reason: "validation_failed",