@devries-cameron20 / t3code-1 / commits / 80f411f13d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

chore(lint): enforce catchConditionalRefailToCatchIf (#25081)

Julius Marminge committed Oct 25, 2026 at 23:01 UTC 80f411f13d2bd0a8b3ef5ba30972c6d4fc9f1bbe
15 files changed +105 -102
apps/server/src/assets/AttachmentUpload.ts
+3 -2
@@ -230,8 +230,9 @@ export const storeAttachmentUpload = Effect.fn("AttachmentUpload.store")(functio
230 }),
231 }).pipe(
232 Effect.as(true),
233 - Effect.catch((error) =>
234 - error.reason._tag === "AlreadyExists" ? Effect.succeed(false) : Effect.fail(error),
233 + Effect.catchIf(
234 + (error) => error.reason._tag === "AlreadyExists",
235 + () => Effect.succeed(false),
236 ),
237 );
238 }),
apps/server/src/orchestration-v2/CheckpointRestoreSafety.ts
+12 -16
@@ -34,15 +34,12 @@ export const isCheckpointRestoreIsolated = Effect.fn("orchestrationV2.isCheckpoi
34 if (!shared && worktreePath !== null) {
35 // Storage cleanup may have removed the worktree; rollback recreates it.
36 const resolve = (target: string) =>
37 - fileSystem
38 - .realPath(target)
39 - .pipe(
40 - Effect.catch((error) =>
41 - error.reason._tag === "NotFound"
42 - ? Effect.succeed(path.resolve(target))
43 - : Effect.fail(error),
44 - ),
45 - );
37 + fileSystem.realPath(target).pipe(
38 + Effect.catchIf(
39 + (error) => error.reason._tag === "NotFound",
40 + (_error) => Effect.succeed(path.resolve(target)),
41 + ),
42 + );
43 const cwd = yield* resolve(scope.cwd);
44 const worktreeCwd = yield* resolve(worktreePath);
45 shared = cwd !== worktreeCwd;
@@ -74,13 +71,12 @@ export const isCheckpointRestoreIsolated = Effect.fn("orchestrationV2.isCheckpoi
71 for (const candidate of paths) {
72 if (checkedPaths.has(candidate)) continue;
73 checkedPaths.add(candidate);
77 - const otherCwd = yield* fileSystem
78 - .realPath(candidate)
79 - .pipe(
80 - Effect.catch((error) =>
81 - error.reason._tag === "NotFound" ? Effect.succeed(null) : Effect.fail(error),
82 - ),
83 - );
74 + const otherCwd = yield* fileSystem.realPath(candidate).pipe(
75 + Effect.catchIf(
76 + (error) => error.reason._tag === "NotFound",
77 + (_error) => Effect.succeed(null),
78 + ),
79 + );
80 if (otherCwd !== null && (contains(cwd, otherCwd) || contains(otherCwd, cwd))) {
81 shared = true;
82 break;
apps/server/src/orchestration-v2/EffectWorker.ts
+8 -8
@@ -177,14 +177,14 @@ export const layerExecutor: Layer.Layer<
177 cause,
178 }),
179 ),
180 - Effect.catch((cause) =>
181 - request.subagent === undefined &&
182 - isNonRetryableProviderTurnControlFailure(
183 - request.type,
184 - Cause.pretty(Cause.fail(cause)),
185 - )
186 - ? Effect.void
187 - : Effect.fail(cause),
180 + Effect.catchIf(
181 + (cause) =>
182 + request.subagent === undefined &&
183 + isNonRetryableProviderTurnControlFailure(
184 + request.type,
185 + Cause.pretty(Cause.fail(cause)),
186 + ),
187 + () => Effect.void,
188 ),
189 Effect.andThen((outcome) =>
190 request.subagent !== undefined && outcome === undefined
apps/server/src/orchestration-v2/ProviderTurnStartService.ts
+8 -8
@@ -505,14 +505,14 @@ export const layer: Layer.Layer<
505 path: worktreePath,
506 }),
507 ),
508 - Effect.catchCause((cause) =>
509 - Cause.hasInterruptsOnly(cause)
510 - ? Effect.failCause(cause)
511 - : Effect.logWarning("provider turn start failed to recreate worktree", {
512 - threadId: projection.thread.id,
513 - worktreePath,
514 - cause: Cause.pretty(cause),
515 - }),
508 + Effect.catchCauseIf(
509 + (cause) => !Cause.hasInterruptsOnly(cause),
510 + (cause) =>
511 + Effect.logWarning("provider turn start failed to recreate worktree", {
512 + threadId: projection.thread.id,
513 + worktreePath,
514 + cause: Cause.pretty(cause),
515 + }),
516 ),
517 );
518 }
apps/server/src/orchestration-v2/RunExecutionService.ts
+7 -7
@@ -926,13 +926,13 @@ export const layer: Layer.Layer<
926 ordinalWithinScope: Math.max(0, input.run.ordinal - 1),
927 })
928 .pipe(
929 - Effect.catchCause((cause) =>
930 - Cause.hasInterruptsOnly(cause)
931 - ? Effect.failCause(cause)
932 - : Effect.logWarning(
933 - "orchestration V2 checkpoint baseline capture failed; starting provider without a baseline",
934 - { runId: input.run.id },
935 - ),
929 + Effect.catchCauseIf(
930 + (cause) => !Cause.hasInterruptsOnly(cause),
931 + (_cause) =>
932 + Effect.logWarning(
933 + "orchestration V2 checkpoint baseline capture failed; starting provider without a baseline",
934 + { runId: input.run.id },
935 + ),
936 ),
937 );
938 if (
apps/server/src/orchestration-v2/ThreadPullRequestService.ts
+7 -7
@@ -318,13 +318,13 @@ export const make = Effect.gen(function* () {
318 });
319 pendingBackfill.delete(thread.id);
320 }).pipe(
321 - Effect.catchCause((cause) =>
322 - Cause.hasInterruptsOnly(cause)
323 - ? Effect.failCause(cause)
324 - : Effect.logWarning("thread pull request update failed", {
325 - threadId: thread.id,
326 - cause: Cause.pretty(cause),
327 - }).pipe(Effect.tap(() => Effect.sync(() => failBackfill([thread])))),
321 + Effect.catchCauseIf(
322 + (cause) => !Cause.hasInterruptsOnly(cause),
323 + (cause) =>
324 + Effect.logWarning("thread pull request update failed", {
325 + threadId: thread.id,
326 + cause: Cause.pretty(cause),
327 + }).pipe(Effect.tap(() => Effect.sync(() => failBackfill([thread])))),
328 ),
329 ),
330 { discard: true },
apps/server/src/orchestration-v2/ThreadSettlementService.ts
+27 -27
@@ -350,13 +350,13 @@ export const make = Effect.gen(function* () {
350 },
351 (effect, thread) =>
352 effect.pipe(
353 - Effect.catchCause((cause) =>
354 - Cause.hasInterruptsOnly(cause)
355 - ? Effect.failCause(cause)
356 - : Effect.logWarning("automatic thread settlement skipped", {
357 - threadId: thread.id,
358 - cause: Cause.pretty(cause),
359 - }).pipe(Effect.as(null)),
353 + Effect.catchCauseIf(
354 + (cause) => !Cause.hasInterruptsOnly(cause),
355 + (cause) =>
356 + Effect.logWarning("automatic thread settlement skipped", {
357 + threadId: thread.id,
358 + cause: Cause.pretty(cause),
359 + }).pipe(Effect.as(null)),
360 ),
361 ),
362 );
@@ -507,13 +507,13 @@ export const make = Effect.gen(function* () {
507 discard: true,
508 });
509 }).pipe(
510 - Effect.catchCause((cause) =>
511 - Cause.hasInterruptsOnly(cause)
512 - ? Effect.failCause(cause)
513 - : Effect.logWarning("automatic thread settlement skipped", {
514 - threadIds: group.map((thread) => thread.id),
515 - cause: Cause.pretty(cause),
516 - }),
510 + Effect.catchCauseIf(
511 + (cause) => !Cause.hasInterruptsOnly(cause),
512 + (cause) =>
513 + Effect.logWarning("automatic thread settlement skipped", {
514 + threadIds: group.map((thread) => thread.id),
515 + cause: Cause.pretty(cause),
516 + }),
517 ),
518 ),
519 { concurrency: 8, discard: true },
@@ -525,12 +525,12 @@ export const make = Effect.gen(function* () {
525 threadId?: ThreadId,
526 ) =>
527 sweep(mergedPullRequest, threadId).pipe(
528 - Effect.catchCause((cause) =>
529 - Cause.hasInterruptsOnly(cause)
530 - ? Effect.failCause(cause)
531 - : Effect.logWarning("automatic thread settlement sweep failed", {
532 - cause: Cause.pretty(cause),
533 - }),
528 + Effect.catchCauseIf(
529 + (cause) => !Cause.hasInterruptsOnly(cause),
530 + (cause) =>
531 + Effect.logWarning("automatic thread settlement sweep failed", {
532 + cause: Cause.pretty(cause),
533 + }),
534 ),
535 );
536 // A thread that just stopped must not wait behind a full sweep or another thread's host
@@ -590,13 +590,13 @@ export const make = Effect.gen(function* () {
590 },
591 (effect, threadId) =>
592 effect.pipe(
593 - Effect.catchCause((cause) =>
594 - Cause.hasInterruptsOnly(cause)
595 - ? Effect.failCause(cause)
596 - : Effect.logWarning("cleaning up a settled thread failed", {
597 - threadId,
598 - cause: Cause.pretty(cause),
599 - }),
593 + Effect.catchCauseIf(
594 + (cause) => !Cause.hasInterruptsOnly(cause),
595 + (cause) =>
596 + Effect.logWarning("cleaning up a settled thread failed", {
597 + threadId,
598 + cause: Cause.pretty(cause),
599 + }),
600 ),
601 ),
602 );
apps/server/src/persistence/initializeV2Database.ts
+6 -7
@@ -39,13 +39,12 @@ export const initializeV2Database = Effect.fn("initializeV2Database")(function*
39 }
40 });
41 // Publish only a complete snapshot, without replacing an existing V2 database.
42 - yield* fs
43 - .link(snapshotPath, destinationPath)
44 - .pipe(
45 - Effect.catch((error) =>
46 - error.reason._tag === "AlreadyExists" ? Effect.void : Effect.fail(error),
47 - ),
48 - );
42 + yield* fs.link(snapshotPath, destinationPath).pipe(
43 + Effect.catchIf(
44 + (error) => error.reason._tag === "AlreadyExists",
45 + (_error) => Effect.void,
46 + ),
47 + );
48 }).pipe(
49 Effect.scoped,
50 Effect.mapError((cause) => new V2DatabaseImportError({ sourcePath, destinationPath, cause })),
apps/server/src/pullRequest/PullRequestService.ts
+6 -4
@@ -2954,8 +2954,9 @@ export const make = Effect.gen(function* () {
2954 ]);
2955 // A replacement reader can join a lookup still finishing its previous reader's cancellation.
2956 return Cache.get(listCache, key).pipe(
2957 - Effect.catchCause((cause) =>
2958 - Cause.hasInterruptsOnly(cause) ? Cache.get(listCache, key) : Effect.failCause(cause),
2957 + Effect.catchCauseIf(
2958 + (cause) => Cause.hasInterruptsOnly(cause),
2959 + (_cause) => Cache.get(listCache, key),
2960 ),
2961 );
2962 };
@@ -3385,8 +3386,9 @@ export const make = Effect.gen(function* () {
3386 if (missing.size === 0) return { stats: held };
3387 const key = statsBatchKey(missing.values());
3388 const { result, at } = yield* Cache.get(listStatsCache, key).pipe(
3388 - Effect.catchCause((cause) =>
3389 - Cause.hasInterruptsOnly(cause) ? Cache.get(listStatsCache, key) : Effect.failCause(cause),
3389 + Effect.catchCauseIf(
3390 + (cause) => Cause.hasInterruptsOnly(cause),
3391 + (_cause) => Cache.get(listStatsCache, key),
3392 ),
3393 );
3394 for (const [key, ref] of missing) {
apps/server/src/sourceControl/SourceControlRepositoryService.ts
+1
@@ -382,6 +382,7 @@ export const make = Effect.gen(function* () {
382 options,
383 ).pipe(
384 Effect.as(prepared.remoteUrl),
385 + // @effect-diagnostics-next-line catchConditionalRefailToCatchIf:off - The condition also narrows httpsUrl for the fallback closure.
386 Effect.catch((sshError) =>
387 httpsUrl === null || !isSshRejection(sshError)
388 ? Effect.fail(sshError)
packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
+3 -2
@@ -1294,8 +1294,9 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1294 for (let attempt = 0; attempt < INSTALL_LOCK_RETRY_COUNT; attempt += 1) {
1295 const acquired = yield* fileSystem.writeFileString(lockPath, "", { flag: "wx" }).pipe(
1296 Effect.as(true),
1297 - Effect.catch((error) =>
1298 - isAlreadyExists(error) ? Effect.succeed(false) : Effect.fail(error),
1297 + Effect.catchIf(
1298 + (error) => isAlreadyExists(error),
1299 + () => Effect.succeed(false),
1300 ),
1301 );
1302 if (acquired) return;
packages/provider-acp/src/server/AcpSessionRuntime.ts
+11 -10
@@ -2221,10 +2221,10 @@ export const make = Effect.fn("AcpSessionRuntime.make")(function* (
2221 );
2222 }
2223 const { sessionId, sessionSetupResult } = yield* setupSession.pipe(
2224 - Effect.catch((error) =>
2225 - !isAcpAuthenticationRequired(error) || options.authenticateOnAuthRequired === false
2226 - ? Effect.fail(error)
2227 - : authenticateAfterRequired(error).pipe(Effect.andThen(setupSession)),
2224 + Effect.catchIf(
2225 + (error) =>
2226 + !(!isAcpAuthenticationRequired(error) || options.authenticateOnAuthRequired === false),
2227 + (error) => authenticateAfterRequired(error).pipe(Effect.andThen(setupSession)),
2228 ),
2229 );
2230
@@ -2578,12 +2578,13 @@ export const make = Effect.fn("AcpSessionRuntime.make")(function* (
2578 ),
2579 (activePrompt) =>
2580 Fiber.join(activePrompt.fiber).pipe(
2581 - Effect.catchCause((cause) =>
2582 - options.cancelBehavior !== "wait-for-prompt" && Cause.hasInterruptsOnly(cause)
2583 - ? Effect.succeed({
2584 - stopReason: "cancelled",
2585 - } satisfies EffectAcpSchema.PromptResponse)
2586 - : Effect.failCause(cause),
2581 + Effect.catchCauseIf(
2582 + (cause) =>
2583 + options.cancelBehavior !== "wait-for-prompt" && Cause.hasInterruptsOnly(cause),
2584 + (_cause) =>
2585 + Effect.succeed({
2586 + stopReason: "cancelled",
2587 + } satisfies EffectAcpSchema.PromptResponse),
2588 ),
2589 Effect.tap(() =>
2590 closeActiveAssistantSegment({ queue: eventQueue, assistantSegmentRef }),
packages/provider-grok/src/server/xaiAcpExtension.ts
+3 -4
@@ -1524,10 +1524,9 @@ export const makeXAiPromptCompletionRuntime = Effect.fn("makeXAiPromptCompletion
1524 .pipe(Effect.forkChild);
1525 return yield* Effect.raceFirst(
1526 Fiber.join(promptRpcFiber).pipe(
1527 - Effect.catchCause((cause) =>
1528 - Cause.hasInterruptsOnly(cause)
1529 - ? Effect.succeed(cancelledResponse)
1530 - : Effect.failCause(cause),
1527 + Effect.catchCauseIf(
1528 + (cause) => Cause.hasInterruptsOnly(cause),
1529 + (_cause) => Effect.succeed(cancelledResponse),
1530 ),
1531 ),
1532 Deferred.await(fallback.deferred),
packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.ts
+2
@@ -907,6 +907,7 @@ export const make = Effect.gen(function* () {
907 : readLineStats(input, pull.version).pipe(Effect.orElseSucceed(() => null)),
908 // Reviewers need `pr:review:read`, which a contents-only token lacks.
909 readPages("getChangeRequest", input, `${path}/reviewers`, Json.GitCafeActorEntries).pipe(
910 + // @effect-diagnostics-next-line catchConditionalRefailToCatchIf:off - catchIf widens this paginated result to any in tsc-rs.
911 Effect.catch((error) =>
912 isForbidden(error) ? Effect.succeed({ items: [], next: null }) : Effect.fail(error),
913 ),
@@ -989,6 +990,7 @@ export const make = Effect.gen(function* () {
990 : // A closed pull request whose branch is gone keeps its head, but git.cafe answers
991 // 404 for commits it no longer has; the conversation still stands without them.
992 readPages(operation, input, `${path}/commits`, Json.GitCafeCommits).pipe(
993 + // @effect-diagnostics-next-line catchConditionalRefailToCatchIf:off - catchIf widens this paginated result to any in tsc-rs.
994 Effect.catch((error) =>
995 error.reason === "not-found"
996 ? Effect.succeed({ items: [], next: null })
tsconfig.base.json
+1
@@ -24,6 +24,7 @@
24 "namespaceImportPackages": ["@effect/platform-node", "effect"],
25 "effectFn": ["span", "inferred-span", "suggested-span"],
26 "diagnosticSeverity": {
27 + "catchConditionalRefailToCatchIf": "error",
28 "tryCatchInEffectGen": "error",
29 "schemaStructWithTag": "error",
30 "preferTypedSchemaDecoder": "error",