From 89ad69b21f75a0609159d3a935b73dda02378d75 Mon Sep 17 00:00:00 2001 From: YuMao233 Date: Sat, 18 Jan 2025 12:56:02 +0800 Subject: [PATCH] fix: del err path check --- daemon/src/entity/commands/pty/pty_start.ts | 26 ++++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/daemon/src/entity/commands/pty/pty_start.ts b/daemon/src/entity/commands/pty/pty_start.ts index 09e8f160..c62793b3 100755 --- a/daemon/src/entity/commands/pty/pty_start.ts +++ b/daemon/src/entity/commands/pty/pty_start.ts @@ -47,15 +47,23 @@ export class GoPtyProcessAdapter extends EventEmitter implements IInstanceProces this.initNamedPipe(); } - private initNamedPipe() { - const fd = fs.openSync(this.pipeName, "w"); - const writePipe = fs.createWriteStream("", { fd }); - writePipe.on("close", () => {}); - writePipe.on("end", () => {}); - writePipe.on("error", (err) => { - logger.error("Pipe error:", this.pipeName, err); - }); - this.pipeClient = writePipe; + private async initNamedPipe() { + try { + const fd = await fs.open(this.pipeName, "w"); + const writePipe = fs.createWriteStream("", { fd }); + writePipe.on("close", () => {}); + writePipe.on("end", () => {}); + writePipe.on("error", (err) => { + logger.error("Pipe error:", this.pipeName, err); + }); + this.pipeClient = writePipe; + } catch (error) { + throw new Error( + $t("TXT_CODE_9d1d244f", { + pipeName: error + }) + ); + } } public resize(w: number, h: number) {