in src/server/server-manager.ts [54:89]
async serverLaunch() {
this.resetConnectionPromise()
try {
const rootDir = await Utils.getWorkspaceGitRoot()
if (!rootDir) {
this.outputChannel.appendLine(
'Unable to determine workspace root. Please ensure you are in a valid git repository.'
)
return
}
const connDetails = await this.connectionDetailsWithInstallCheck(rootDir)
if (!connDetails) {
this.connectionReject(
'Unable to find connection details for Bazel BSP. Please ensure the server is installed.'
)
return
}
const cmd = connDetails.argv[0]
const args = connDetails.argv.slice(1)
let childProcess = cp.spawn(cmd, args, {cwd: rootDir})
childProcess.stderr.on('data', data => {
// Per BSP spec, issues with the server process are reported via stderr.
this.outputChannel.appendLine(`[bsp server process] ${data.toString()}`)
})
let connection = rpc.createMessageConnection(
new rpc.StreamMessageReader(childProcess.stdout),
new rpc.StreamMessageWriter(childProcess.stdin)
)
connection.listen()
this.connectionResolve(connection)
} catch (e) {
// TODO(IDE-946): Reinstall prompt if spawn fails.
this.connectionReject(e)
}
}