Skip to content

Commit 6f14b8b

Browse files
committed
Add separate handler for error
Feels like it parallels better with the other handlers.
1 parent b73ea2f commit 6f14b8b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/node/vscode.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,26 @@ export class VscodeProvider {
122122
proc: cp.ChildProcess,
123123
fn: (message: ipc.VscodeMessage) => message is T,
124124
): Promise<T> {
125-
return new Promise((resolve, _reject) => {
125+
return new Promise((resolve, reject) => {
126126
const cleanup = () => {
127-
proc.off("error", reject)
127+
proc.off("error", onError)
128128
proc.off("exit", onExit)
129129
proc.off("message", onMessage)
130130
clearTimeout(timeout)
131131
}
132132

133133
const timeout = setTimeout(() => {
134134
cleanup()
135-
_reject(new Error("timed out"))
135+
reject(new Error("timed out"))
136136
}, this.timeoutInterval)
137137

138-
const reject = (error: Error) => {
138+
const onError = (error: Error) => {
139139
cleanup()
140-
_reject(error)
140+
reject(error)
141141
}
142142

143143
const onExit = (code: number | null) => {
144+
cleanup()
144145
reject(new Error(`VS Code exited unexpectedly with code ${code}`))
145146
}
146147

@@ -153,7 +154,7 @@ export class VscodeProvider {
153154
}
154155

155156
proc.on("message", onMessage)
156-
proc.on("error", reject)
157+
proc.on("error", onError)
157158
proc.on("exit", onExit)
158159
})
159160
}

0 commit comments

Comments
 (0)