Skip to content

Commit 02e642a

Browse files
committed
Fix assertValidCwd to only map NotFound errors to TerminalCwdError
Previously, all fileSystem.stat failures were unconditionally mapped to TerminalCwdError with reason 'notFound', including permission-denied and other IO errors. This made non-ENOENT failures impossible to diagnose. Now only PlatformError with reason._tag 'NotFound' produces the TerminalCwdError; all other stat errors are re-raised as defects, matching the original pre-refactor behavior that checked for ENOENT.
1 parent 1b3aa17 commit 02e642a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

apps/server/src/terminal/Layers/Manager.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -977,13 +977,16 @@ export const makeTerminalManagerWithOptions = Effect.fn("makeTerminalManagerWith
977977

978978
const assertValidCwd = Effect.fn("terminal.assertValidCwd")(function* (cwd: string) {
979979
const stats = yield* fileSystem.stat(cwd).pipe(
980-
Effect.mapError(
981-
(cause) =>
982-
new TerminalCwdError({
983-
cwd,
984-
reason: "notFound",
985-
cause,
986-
}),
980+
Effect.catch((error) =>
981+
error.reason._tag === "NotFound"
982+
? Effect.fail(
983+
new TerminalCwdError({
984+
cwd,
985+
reason: "notFound",
986+
cause: error,
987+
}),
988+
)
989+
: Effect.die(error),
987990
),
988991
);
989992
if (stats.type !== "Directory") {

0 commit comments

Comments
 (0)