mirror of https://github.com/coder/code-server.git
Unbind message handler itself after getting message
Also switch `once` to `on` since we `off` them later anyway so no point in making Node do it twice.
This commit is contained in:
parent
e1702a1d21
commit
b73ea2fea2
|
@ -126,6 +126,7 @@ export class VscodeProvider {
|
||||||
const cleanup = () => {
|
const cleanup = () => {
|
||||||
proc.off("error", reject)
|
proc.off("error", reject)
|
||||||
proc.off("exit", onExit)
|
proc.off("exit", onExit)
|
||||||
|
proc.off("message", onMessage)
|
||||||
clearTimeout(timeout)
|
clearTimeout(timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,16 +144,17 @@ export class VscodeProvider {
|
||||||
reject(new Error(`VS Code exited unexpectedly with code ${code}`))
|
reject(new Error(`VS Code exited unexpectedly with code ${code}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
proc.on("message", (message: ipc.VscodeMessage) => {
|
const onMessage = (message: ipc.VscodeMessage) => {
|
||||||
logger.trace("got message from vscode", field("message", message))
|
logger.trace("got message from vscode", field("message", message))
|
||||||
if (fn(message)) {
|
if (fn(message)) {
|
||||||
cleanup()
|
cleanup()
|
||||||
resolve(message)
|
resolve(message)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
proc.once("error", reject)
|
proc.on("message", onMessage)
|
||||||
proc.once("exit", onExit)
|
proc.on("error", reject)
|
||||||
|
proc.on("exit", onExit)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue