Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/ipcBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,13 @@ export function registerGlobalIpcHandlers() {
}
}
});

// chokidar 在监听/遍历出错时会 emit "error";若无监听器,EventEmitter 会把错误
// 抛成主进程 uncaughtException(例如 \\wsl.localhost\ 下对 Linux 软链接 lstat 返回
// EISDIR)。这里吞掉并记录,避免整个应用崩溃。
watcher.on("error", (error) => {
console.warn("[file:watch] watcher error:", error);
});
}

// 新增的文件 - 添加到 watcher
Expand Down Expand Up @@ -1671,6 +1678,12 @@ export function registerGlobalIpcHandlers() {
directoryWatcher.on("unlink", notifyChanged);
directoryWatcher.on("addDir", notifyChanged);
directoryWatcher.on("unlinkDir", notifyChanged);
// chokidar 递归遍历目录时若对某个条目 lstat 失败会 emit "error"。典型场景:监听
// \\wsl.localhost\ (WSL/9P) 下的目录,对 Linux 软链接(如 *.so.0)lstat 返回 EISDIR。
// 没有该监听器时错误会冒泡为主进程 uncaughtException 导致崩溃,这里吞掉并记录。
directoryWatcher.on("error", (error) => {
console.warn("[workspace:watchDirectory] watcher error:", error);
});
});

// 停止监听目录
Expand Down
8 changes: 7 additions & 1 deletion src/renderer/utils/workspacePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ export function isAbsoluteLocalPath(pathValue: string): boolean {
return pathValue.startsWith("/");
}

// 注意:本模块在渲染进程执行(nodeIntegration:false),渲染进程里 process.platform 不可用,
// platform.ts 的 isWindows 会恒为 false。因此这里【不能】用 isWindows 做前置短路,否则本防护
// 会永远失效——曾导致打开 WSL 文件时仍自动加载工作区,进而对 \\wsl.localhost\ 下的 Linux 软链接
// (如 librockchip_mpp.so.0)lstat 触发 EISDIR,使主进程未捕获异常崩溃。
// UNC 路径(\\wsl.localhost\、\\wsl$\、\\server\share)本身是 Windows 专有写法,不会出现在其他
// 平台的合法路径里,无需平台判断即可安全识别为远程路径。
export function isRemoteWorkspacePath(pathValue: string): boolean {
if (!pathValue || !isWindows) return false;
if (!pathValue) return false;

return /^\\\\wsl(?:\$|\.localhost)\\/i.test(pathValue) || /^\\\\(?![?.]\\)/.test(pathValue);
}
Expand Down
Loading