debug(service-party-app): 添加 TSS 进程详细调试日志

- 输出二进制文件路径和存在性检查
- 输出传递给 TSS 的参与者列表 JSON
- 输出完整的命令行参数
- 收集并输出 stderr 内容
- 帮助诊断 TSS 进程 exit code 1 问题

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-29 11:47:37 -08:00
parent aa9171ce2c
commit c94f3e4d83
1 changed files with 16 additions and 4 deletions

View File

@ -198,12 +198,16 @@ export class TSSHandler extends EventEmitter {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
const binaryPath = this.getTSSBinaryPath(); const binaryPath = this.getTSSBinaryPath();
console.log(`[TSS] Binary path: ${binaryPath}`);
console.log(`[TSS] Binary exists: ${fs.existsSync(binaryPath)}`);
// 构建参与者列表 JSON // 构建参与者列表 JSON
const participantsJson = JSON.stringify(participants); const participantsJson = JSON.stringify(participants);
console.log(`[TSS] Participants: ${participantsJson}`);
console.log(`[TSS] partyIndex=${partyIndex}, threshold=${threshold.t}-of-${threshold.n}`);
// 启动 TSS 子进程 // 启动 TSS 子进程
this.tssProcess = spawn(binaryPath, [ const args = [
'keygen', 'keygen',
'--session-id', sessionId, '--session-id', sessionId,
'--party-id', partyId, '--party-id', partyId,
@ -212,9 +216,13 @@ export class TSSHandler extends EventEmitter {
'--threshold-n', threshold.n.toString(), '--threshold-n', threshold.n.toString(),
'--participants', participantsJson, '--participants', participantsJson,
'--password', encryptionPassword, '--password', encryptionPassword,
]); ];
console.log(`[TSS] Spawning: ${binaryPath} ${args.join(' ')}`);
this.tssProcess = spawn(binaryPath, args);
let resultData = ''; let resultData = '';
let stderrData = '';
// 如果没有预订阅,现在订阅消息 // 如果没有预订阅,现在订阅消息
// 如果已经预订阅,消息监听器已经注册,不需要重复注册 // 如果已经预订阅,消息监听器已经注册,不需要重复注册
@ -254,7 +262,9 @@ export class TSSHandler extends EventEmitter {
// 处理标准错误 // 处理标准错误
this.tssProcess.stderr?.on('data', (data: Buffer) => { this.tssProcess.stderr?.on('data', (data: Buffer) => {
console.error('[TSS Error]', data.toString()); const errorText = data.toString();
stderrData += errorText;
console.error('[TSS stderr]', errorText);
}); });
// 处理进程退出 // 处理进程退出
@ -289,7 +299,9 @@ export class TSSHandler extends EventEmitter {
reject(new Error(`Failed to parse keygen result: ${e}`)); reject(new Error(`Failed to parse keygen result: ${e}`));
} }
} else { } else {
reject(new Error(`Keygen process exited with code ${code}`)); const errorMsg = stderrData.trim() || `Keygen process exited with code ${code}`;
console.error(`[TSS] Process failed: code=${code}, stderr=${stderrData}`);
reject(new Error(errorMsg));
} }
}); });