@trim21/personal-pi-extensions 0.0.318 → 0.0.321
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/lsp/client.ts +19 -3
- package/src/opencode/bash.ts +1 -1
package/package.json
CHANGED
package/src/lib/lsp/client.ts
CHANGED
|
@@ -170,10 +170,22 @@ async function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
|
|
|
170
170
|
|
|
171
171
|
function stopProcess(process: LspServerHandle["process"]): Promise<void> {
|
|
172
172
|
if (process.exitCode !== null) return Promise.resolve();
|
|
173
|
-
|
|
173
|
+
try {
|
|
174
|
+
process.kill();
|
|
175
|
+
} catch {
|
|
176
|
+
// Windows 上对已退出/从未成功启动的进程 kill 会抛 EINVAL
|
|
177
|
+
return Promise.resolve();
|
|
178
|
+
}
|
|
174
179
|
return new Promise((resolve) => {
|
|
175
180
|
process.once("exit", () => resolve());
|
|
176
|
-
|
|
181
|
+
process.once("error", () => resolve());
|
|
182
|
+
setTimeout(() => {
|
|
183
|
+
try {
|
|
184
|
+
process.kill("SIGKILL");
|
|
185
|
+
} catch {
|
|
186
|
+
// 进程已退出,忽略
|
|
187
|
+
}
|
|
188
|
+
}, 1_000).unref();
|
|
177
189
|
});
|
|
178
190
|
}
|
|
179
191
|
|
|
@@ -289,7 +301,11 @@ export async function create(input: CreateInput): Promise<LspClient> {
|
|
|
289
301
|
},
|
|
290
302
|
}),
|
|
291
303
|
initializeTimeoutMs,
|
|
292
|
-
).catch((error: unknown) => {
|
|
304
|
+
).catch(async (error: unknown) => {
|
|
305
|
+
// 握手失败(超时/拒绝)时清理连接并终止已 spawn 的子进程,避免进程泄漏
|
|
306
|
+
connection.end();
|
|
307
|
+
connection.dispose();
|
|
308
|
+
await stopProcess(input.server.process);
|
|
293
309
|
throw new InitializeError(input.serverID, error);
|
|
294
310
|
});
|
|
295
311
|
|
package/src/opencode/bash.ts
CHANGED
|
@@ -38,7 +38,7 @@ export default function opencodeBash(
|
|
|
38
38
|
workdir: Type.Optional(
|
|
39
39
|
Type.String({
|
|
40
40
|
description:
|
|
41
|
-
"Working directory to execute the command in. Defaults to the current directory; relative paths resolve from there.",
|
|
41
|
+
"Working directory to execute the command in. Defaults to the current directory; relative paths resolve from there. prefer use this argument over `cd ...`",
|
|
42
42
|
}),
|
|
43
43
|
),
|
|
44
44
|
timeout: Type.Optional(
|