mirror of
https://github.com/sst/opencode.git
synced 2025-07-10 01:24:59 +00:00
add typescript lsp timeout if it fails to start
This commit is contained in:
parent
4a878b88c0
commit
00ea5082e7
2 changed files with 7 additions and 2 deletions
|
@ -53,7 +53,10 @@ export namespace LSP {
|
|||
serverID: server.id,
|
||||
server: handle,
|
||||
root,
|
||||
}).catch((err) => log.error("", { error: err }))
|
||||
}).catch((err) => {
|
||||
handle.process.kill()
|
||||
log.error("", { error: err })
|
||||
})
|
||||
if (!client) break
|
||||
clients.push(client)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import fs from "fs/promises"
|
|||
import { unique } from "remeda"
|
||||
import { Ripgrep } from "../file/ripgrep"
|
||||
import type { LSPClient } from "./client"
|
||||
import { withTimeout } from "../util/timeout"
|
||||
|
||||
export namespace LSPServer {
|
||||
const log = Log.create({ service: "lsp.server" })
|
||||
|
@ -69,7 +70,7 @@ export namespace LSPServer {
|
|||
glob: ["*.ts", "*.tsx", "*.js", "*.jsx", "*.mjs", "*.cjs", "*.mts", "*.cts"],
|
||||
limit: 1,
|
||||
})
|
||||
await new Promise<void>(async (resolve) => {
|
||||
const wait = new Promise<void>(async (resolve) => {
|
||||
const notif = lsp.connection.onNotification("$/progress", (params) => {
|
||||
if (params.value.kind !== "end") return
|
||||
notif.dispose()
|
||||
|
@ -77,6 +78,7 @@ export namespace LSPServer {
|
|||
})
|
||||
await lsp.notify.open({ path: path.join(lsp.root, hint) })
|
||||
})
|
||||
await withTimeout(wait, 5_000)
|
||||
},
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue