The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 17:00 UTC
chore(lint): enforce tryCatchInEffectGen (#25097)
Julius Marminge committed
Oct 25, 2026 at 18:18 UTC
a0b246d0deec3b9ab5153f856aa251272abfe17f
5 files changed
+40
-33
apps/server/src/mcp/AcpMcpStdioBridge.ts
+4
-5
@@ -4,6 +4,7 @@ import * as NodeReadline from "node:readline";
4
5
import * as Cause from "effect/Cause";
6
import * as Effect from "effect/Effect";
7
+import * as Result from "effect/Result";
8
import * as Fiber from "effect/Fiber";
9
import * as Scope from "effect/Scope";
10
import * as Stream from "effect/Stream";
@@ -273,13 +274,11 @@ export function runAcpMcpStdioBridge(options: AcpMcpStdioBridgeOptions): Effect.
274
line: string,
275
): Effect.fn.Return<void> {
276
if (line.trim().length === 0) return;
276
- let parsed: unknown;
277
- try {
278
- parsed = JSON.parse(line);
279
- } catch {
277
+ const parsed = yield* Effect.try((): unknown => JSON.parse(line)).pipe(Effect.result);
278
+ if (Result.isFailure(parsed)) {
279
return yield* respondWithError(null, "Parse error", -32700);
280
}
282
- const envelope = asEnvelope(parsed);
281
+ const envelope = asEnvelope(parsed.success);
282
if (envelope === null) return;
283
const isResponse = envelope.id !== undefined && ("result" in envelope || "error" in envelope);
284
const isSessionHandshake =
apps/server/src/orchestration-v2/http.ts
+6
-3
@@ -5,6 +5,7 @@ import {
5
} from "@t3tools/contracts";
6
import * as DateTime from "effect/DateTime";
7
import * as Effect from "effect/Effect";
8
+import * as Result from "effect/Result";
9
import * as Predicate from "effect/Predicate";
10
import * as Schema from "effect/Schema";
11
import * as HttpApiBuilder from "effect/http-api/HttpApiBuilder";
@@ -245,9 +246,11 @@ export const layer = HttpApiBuilder.group(
246
Effect.fn("environment.orchestration.threadHistoryPage")(function* (args) {
247
yield* annotateEnvironmentRequest(args.endpoint.name);
248
yield* requireEnvironmentScope(AuthOrchestrationReadScope);
248
- try {
249
- decodeThreadHistoryCursor(args.query.cursor);
250
- } catch (cause) {
249
+ const decoded = yield* Effect.try(() =>
250
+ decodeThreadHistoryCursor(args.query.cursor),
251
+ ).pipe(Effect.result);
252
+ if (Result.isFailure(decoded)) {
253
+ const cause = decoded.failure.cause;
254
if (cause instanceof InvalidThreadHistoryCursorError)
255
return yield* failEnvironmentInvalidRequest("invalid_history_cursor");
256
return yield* failEnvironmentInternal("orchestration_thread_history_failed", cause);
packages/provider-acp/src/server/AcpSessionRuntime.ts
+13
-12
@@ -10,6 +10,7 @@ import * as Crypto from "effect/Crypto";
10
import * as Deferred from "effect/Deferred";
11
import * as Duration from "effect/Duration";
12
import * as Effect from "effect/Effect";
13
+import * as Result from "effect/Result";
14
import * as Exit from "effect/Exit";
15
import * as Fiber from "effect/Fiber";
16
import * as Layer from "effect/Layer";
@@ -482,19 +483,18 @@ export function terminateLinuxCgroupLease(
483
let lastRemovalFailure: { readonly cause: unknown } | null = null;
484
for (let attempt = 0; attempt < 200; attempt += 1) {
485
if (!lease.exists()) return;
485
- try {
486
- lease.kill();
487
- } catch (cause) {
486
+ const killed = yield* Effect.try(() => lease.kill()).pipe(Effect.result);
487
+ if (Result.isFailure(killed)) {
488
+ const cause = killed.failure.cause;
489
const code = (cause as NodeJS.ErrnoException | undefined)?.code;
490
if (code !== "ENOENT") return yield* failure("kill", cause);
491
if (!lease.exists()) return;
492
yield* Effect.sleep("10 millis");
493
continue;
494
}
494
- let populated: boolean;
495
- try {
496
- populated = lease.populated();
497
- } catch (cause) {
495
+ const populated = yield* Effect.try(() => lease.populated()).pipe(Effect.result);
496
+ if (Result.isFailure(populated)) {
497
+ const cause = populated.failure.cause;
498
const code = (cause as NodeJS.ErrnoException | undefined)?.code;
499
if (code === "ENOENT" && !lease.exists()) return;
500
if (code === "ENOENT") {
@@ -503,21 +503,22 @@ export function terminateLinuxCgroupLease(
503
}
504
return yield* failure("read state for", cause);
505
}
506
- if (populated) {
506
+ if (populated.success) {
507
lastRemovalFailure = null;
508
yield* Effect.sleep("10 millis");
509
continue;
510
}
511
- try {
512
- lease.remove();
513
- lastRemovalFailure = null;
514
- } catch (cause) {
511
+ const removed = yield* Effect.try(() => lease.remove()).pipe(Effect.result);
512
+ if (Result.isFailure(removed)) {
513
+ const cause = removed.failure.cause;
514
const code = (cause as NodeJS.ErrnoException | undefined)?.code;
515
if (code === "ENOENT" && !lease.exists()) return;
516
if (code !== "EBUSY" && code !== "ENOTEMPTY" && code !== "ENOENT") {
517
return yield* failure("remove", cause);
518
}
519
lastRemovalFailure = { cause };
520
+ } else {
521
+ lastRemovalFailure = null;
522
}
523
if (!lease.exists()) return;
524
yield* Effect.sleep("10 millis");
packages/shared/src/nodeSqliteClient.ts
+16
-13
@@ -6,6 +6,7 @@ import * as Cache from "effect/Cache";
6
import * as Clock from "effect/Clock";
7
import * as Duration from "effect/Duration";
8
import * as Effect from "effect/Effect";
9
+import * as Result from "effect/Result";
10
import * as Exit from "effect/Exit";
11
import * as Fiber from "effect/Fiber";
12
import { identity } from "effect/Function";
@@ -640,21 +641,23 @@ const startCheckpointWorker = Effect.fnUntraced(function* (
641
}
642
const frames = writer.prepare("PRAGMA wal_checkpoint(NOOP)");
643
const sizeLimit = writer.prepare("PRAGMA journal_size_limit");
643
- let worker: NodeWorkerThreads.Worker;
644
- try {
645
- worker = new NodeWorkerThreads.Worker(checkpointWorkerSource, {
646
- eval: true,
647
- workerData: {
648
- filename,
649
- frames: CHECKPOINT_FRAMES,
650
- backpressureFrames: CHECKPOINT_BACKPRESSURE_FRAMES,
651
- idleMs: CHECKPOINT_IDLE_MS,
652
- },
653
- });
654
- } catch (cause) {
655
- yield* warn(String(cause));
644
+ const started = yield* Effect.try(
645
+ () =>
646
+ new NodeWorkerThreads.Worker(checkpointWorkerSource, {
647
+ eval: true,
648
+ workerData: {
649
+ filename,
650
+ frames: CHECKPOINT_FRAMES,
651
+ backpressureFrames: CHECKPOINT_BACKPRESSURE_FRAMES,
652
+ idleMs: CHECKPOINT_IDLE_MS,
653
+ },
654
+ }),
655
+ ).pipe(Effect.result);
656
+ if (Result.isFailure(started)) {
657
+ yield* warn(String(started.failure.cause));
658
return undefined;
659
}
660
+ const worker = started.success;
661
const runFork = Effect.runForkWith(yield* Effect.context<never>());
662
let stopped = false;
663
let generation = 0;
tsconfig.base.json
+1
@@ -24,6 +24,7 @@
24
"namespaceImportPackages": ["@effect/platform-node", "effect"],
25
"effectFn": ["span", "inferred-span", "suggested-span"],
26
"diagnosticSeverity": {
27
+ "tryCatchInEffectGen": "error",
28
"schemaStructWithTag": "error",
29
"preferTypedSchemaDecoder": "error",
30
"catchUnfailableEffect": "error",