This commit is contained in:
2026-09-20 23:35:03 +08:00
parent 941ce4baab
commit 388c700996
19 changed files with 393 additions and 71 deletions

View File

@@ -70,6 +70,15 @@ class KeyHelper {
this.ps.stderr.on('data', (chunk) => {
console.error('[keyhelper stderr]', chunk.toString());
});
// spawn 失败(powershell.exe 缺失 / 被策略禁用)走 'error' 事件而不是
// 抛异常 —— 不挂监听的话 Node 把它升级成 uncaughtException 打挂主进程。
// 'error' 之后 'exit' 可能不再触发,重连也要在这里做;
// _reconnect 有 _reconnectTimer 去重,两个事件都到也只重连一次。
this.ps.on('error', (err) => {
console.error('[keyhelper] powershell spawn error:', err.message);
this._rejectAll(err);
this._reconnect();
});
this.ps.on('exit', (code) => {
console.error('[keyhelper] powershell exited with code', code);
this._rejectAll(new Error('keyhelper exited'));