mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 05:28:16 +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,
|
serverID: server.id,
|
||||||
server: handle,
|
server: handle,
|
||||||
root,
|
root,
|
||||||
}).catch((err) => log.error("", { error: err }))
|
}).catch((err) => {
|
||||||
|
handle.process.kill()
|
||||||
|
log.error("", { error: err })
|
||||||
|
})
|
||||||
if (!client) break
|
if (!client) break
|
||||||
clients.push(client)
|
clients.push(client)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import fs from "fs/promises"
|
||||||
import { unique } from "remeda"
|
import { unique } from "remeda"
|
||||||
import { Ripgrep } from "../file/ripgrep"
|
import { Ripgrep } from "../file/ripgrep"
|
||||||
import type { LSPClient } from "./client"
|
import type { LSPClient } from "./client"
|
||||||
|
import { withTimeout } from "../util/timeout"
|
||||||
|
|
||||||
export namespace LSPServer {
|
export namespace LSPServer {
|
||||||
const log = Log.create({ service: "lsp.server" })
|
const log = Log.create({ service: "lsp.server" })
|
||||||
|
@ -69,7 +70,7 @@ export namespace LSPServer {
|
||||||
glob: ["*.ts", "*.tsx", "*.js", "*.jsx", "*.mjs", "*.cjs", "*.mts", "*.cts"],
|
glob: ["*.ts", "*.tsx", "*.js", "*.jsx", "*.mjs", "*.cjs", "*.mts", "*.cts"],
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
await new Promise<void>(async (resolve) => {
|
const wait = new Promise<void>(async (resolve) => {
|
||||||
const notif = lsp.connection.onNotification("$/progress", (params) => {
|
const notif = lsp.connection.onNotification("$/progress", (params) => {
|
||||||
if (params.value.kind !== "end") return
|
if (params.value.kind !== "end") return
|
||||||
notif.dispose()
|
notif.dispose()
|
||||||
|
@ -77,6 +78,7 @@ export namespace LSPServer {
|
||||||
})
|
})
|
||||||
await lsp.notify.open({ path: path.join(lsp.root, hint) })
|
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