authorgravatar for 888122+bkntr@users.noreply.github.combkntr <888122+bkntr@users.noreply.github.com> 2026-08-11 09:03:18+05:30
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-08-10 23:33:18-04:00
log1fa315ea93f24e6f72455e234fa84a97de28492b
treea7475b9471edcb34cb4331dc8b006e0965fc6f75
parentf9730979c1046e3e69ac89aa86882ebf8b2be9a6
signature Signed by PGP key B5690EEEBB952194

fix(server): skip Linux libc detection on Windows/macOS (#5354)


2 files changed, 33 insertions(+), 3 deletions(-)

apps/server/src/resourceTelemetry/ResourceMonitorBinary.test.ts+31-1
......@@ -4,7 +4,7 @@ import {
44 HostProcessEnvironment,
55 HostProcessPlatform,
66} from "@t3tools/shared/hostProcess";
7import { assert, describe, it } from "@effect/vitest";
7import { afterEach, assert, describe, expect, it, vi } from "@effect/vitest";
88import * as Effect from "effect/Effect";
99import * as FileSystem from "effect/FileSystem";
1010
......@@ -12,6 +12,36 @@ import { ServerConfig } from "../config.ts";
1212import * as ResourceMonitorBinary from "./ResourceMonitorBinary.ts";
1313
1414describe("ResourceMonitorBinary", () => {
15 afterEach(() => {
16 vi.restoreAllMocks();
17 });
18
19 it.effect("skips Linux libc detection on Windows", () =>
20 Effect.gen(function* () {
21 const getReport = vi.spyOn(process.report, "getReport").mockImplementation(() => {
22 throw new Error("Linux libc detection must not run on Windows");
23 });
24 const fileSystem = yield* FileSystem.FileSystem;
25 const baseDir = yield* fileSystem.makeTempDirectoryScoped({
26 prefix: "t3-resource-monitor-binary-",
27 });
28 const binaryPath = `${baseDir}/t3-resource-monitor.exe`;
29 yield* fileSystem.writeFileString(binaryPath, "binary");
30
31 const service = yield* ResourceMonitorBinary.make().pipe(
32 Effect.provide(ServerConfig.layerTest(process.cwd(), baseDir)),
33 Effect.provideService(HostProcessPlatform, "win32"),
34 Effect.provideService(HostProcessArchitecture, "arm64"),
35 Effect.provideService(HostProcessEnvironment, {
36 T3CODE_RESOURCE_MONITOR_PATH: binaryPath,
37 }),
38 );
39
40 assert.equal(yield* service.resolve, binaryPath);
41 expect(getReport).not.toHaveBeenCalled();
42 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
43 );
44
1545 it.effect("resolves an executable override", () =>
1646 Effect.gen(function* () {
1747 const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/resourceTelemetry/ResourceMonitorBinary.ts+2-2
......@@ -106,7 +106,7 @@ export function resourceMonitorPlatformKey(
106106export function resourceMonitorRustTarget(
107107 platform: NodeJS.Platform,
108108 architecture: NodeJS.Architecture,
109 linuxLibc: ResourceMonitorLinuxLibc,
109 linuxLibc?: ResourceMonitorLinuxLibc,
110110): string | undefined {
111111 if (platform === "darwin") {
112112 return architecture === "arm64"
......@@ -142,7 +142,7 @@ export const make = Effect.fn("resourceTelemetry.resourceMonitorBinary.make")(fu
142142 const platform = yield* HostProcessPlatform;
143143 const architecture = yield* HostProcessArchitecture;
144144 const environment = yield* HostProcessEnvironment;
145 const linuxLibc = yield* ResourceMonitorHostLinuxLibc;
145 const linuxLibc = platform === "linux" ? yield* ResourceMonitorHostLinuxLibc : undefined;
146146 const executableName = binaryName(platform);
147147 const platformKey = resourceMonitorPlatformKey(platform, architecture);
148148 const rustTarget = resourceMonitorRustTarget(platform, architecture, linuxLibc);