The best way to control Claude Code, Codex and more from any computer or phone
fix(server): a directory no longer resolves as the resource monitor binary (#16838)
Co-authored-by: Yash Singh <saiansh2525@gmail.com>
Furox committed
Oct 11, 2026 at 09:38 UTC
8dfee385721d5a0d613803da430e7b2276fadec5
2 files changed
+30
-3
apps/server/src/resourceTelemetry/ResourceMonitorBinary.test.ts
+22
@@ -115,6 +115,28 @@ describe("ResourceMonitorBinary", () => {
115
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
116
);
117
118
+ it.effect("rejects a directory override", () =>
119
+ Effect.gen(function* () {
120
+ const fileSystem = yield* FileSystem.FileSystem;
121
+ const baseDir = yield* fileSystem.makeTempDirectoryScoped({
122
+ prefix: "t3-resource-monitor-binary-",
123
+ });
124
+
125
+ const service = yield* ResourceMonitorBinary.make().pipe(
126
+ Effect.provide(ServerConfig.layerTest(process.cwd(), baseDir)),
127
+ Effect.provideService(HostProcess.Platform, "win32"),
128
+ Effect.provideService(HostProcess.Architecture, "arm64"),
129
+ Effect.provideService(HostProcess.Environment, {
130
+ T3CODE_RESOURCE_MONITOR_PATH: baseDir,
131
+ }),
132
+ );
133
+ const error = yield* Effect.flip(service.resolve);
134
+
135
+ assert.instanceOf(error, ResourceMonitorBinary.ResourceMonitorBinaryNotExecutable);
136
+ assert.equal(error.path, baseDir);
137
+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
138
+ );
139
+
140
it.effect("rejects unsupported platform and architecture pairs", () =>
141
Effect.gen(function* () {
142
const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/resourceTelemetry/ResourceMonitorBinary.ts
+8
-3
@@ -196,9 +196,14 @@ export const make = Effect.fn("resourceTelemetry.resourceMonitorBinary.make")(fu
196
const exists = yield* fileSystem.exists(candidate).pipe(Effect.orElseSucceed(() => false));
197
if (!exists) continue;
198
199
- if (platform !== "win32") {
200
- const stat = yield* fileSystem.stat(candidate).pipe(Effect.option);
201
- if (Option.isSome(stat) && (stat.value.mode & 0o111) === 0) {
199
+ const stat = yield* fileSystem.stat(candidate).pipe(Effect.option);
200
+ if (Option.isSome(stat)) {
201
+ // Directories are executable-looking on win32, where the exec-bit test
202
+ // below is skipped, and only fail later at spawn.
203
+ const unusable =
204
+ stat.value.type === "Directory" ||
205
+ (platform !== "win32" && (stat.value.mode & 0o111) === 0);
206
+ if (unusable) {
207
return yield* new ResourceMonitorBinaryNotExecutable({
208
path: candidate,
209
mode: stat.value.mode,