fix(gsd): handle deleted cwd in projectRoot to prevent ENOENT crash
process.cwd() throws ENOENT when the worktree directory was deleted during a failed merge. Every /gsd command calls projectRoot(), causing the entire extension to crash. Now catches the ENOENT and falls back to HOME directory. Closes #3598 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b4c6229360
commit
5cc2e24800
1 changed files with 7 additions and 1 deletions
|
|
@ -13,7 +13,13 @@ export interface GsdDispatchContext {
|
|||
}
|
||||
|
||||
export function projectRoot(): string {
|
||||
const cwd = process.cwd();
|
||||
let cwd: string;
|
||||
try {
|
||||
cwd = process.cwd();
|
||||
} catch {
|
||||
// cwd directory was deleted (e.g. worktree teardown) — fall back to HOME (#3598)
|
||||
cwd = process.env.HOME ?? "/";
|
||||
}
|
||||
const root = resolveProjectRoot(cwd);
|
||||
if (root !== cwd) {
|
||||
assertSafeDirectory(cwd);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue