fix(ext): v0.5.5 wrong-LS 자동 복구 — fixLSConnection export + 'input not registered' 감지 시 LS 재연결 + 1회 retry
This commit is contained in:
@@ -426,6 +426,7 @@ export async function tryApprovalStrategies(approved: boolean, sessionId: string
|
||||
},
|
||||
},
|
||||
];
|
||||
let lastRpcError = '';
|
||||
for (let i = 0; i < protoVariants.length; i++) {
|
||||
try {
|
||||
const payload = protoVariants[i];
|
||||
@@ -434,7 +435,35 @@ export async function tryApprovalStrategies(approved: boolean, sessionId: string
|
||||
ctx.logToFile(`[APPROVAL-PROTO-${i}] ✅ SUCCESS: ${JSON.stringify(rpcResult).substring(0, 200)}`);
|
||||
return `RPC-PROTO-${i}:HandleCascadeUserInteraction(${typeLower})`;
|
||||
} catch (e: any) {
|
||||
ctx.logToFile(`[APPROVAL-PROTO-${i}] ❌ ${e.message.substring(0, 300)}`);
|
||||
lastRpcError = e.message || '';
|
||||
ctx.logToFile(`[APPROVAL-PROTO-${i}] ❌ ${lastRpcError.substring(0, 300)}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Auto-recovery: wrong-LS detection ──────────────────────
|
||||
// All 3 proto variants failed. If the error is "input not registered",
|
||||
// SDK is likely connected to wrong LS process. Attempt fixLSConnection
|
||||
// and retry ONE time to avoid permanent failure.
|
||||
if (ctx.fixLSConnection && lastRpcError.includes('input not registered')) {
|
||||
ctx.logToFile('[APPROVAL] ⚠️ wrong-LS detected ("input not registered"), attempting LS fix...');
|
||||
try {
|
||||
const lsChanged = await ctx.fixLSConnection();
|
||||
if (lsChanged) {
|
||||
ctx.logToFile('[APPROVAL] LS reconnected — retrying first proto variant...');
|
||||
try {
|
||||
const retryPayload = protoVariants[0];
|
||||
ctx.logToFile(`[APPROVAL-RETRY] HandleCascadeUserInteraction(${JSON.stringify(retryPayload).substring(0, 250)})`);
|
||||
const retryResult = await ctx.sdk.ls.rawRPC('HandleCascadeUserInteraction', retryPayload);
|
||||
ctx.logToFile(`[APPROVAL-RETRY] ✅ SUCCESS: ${JSON.stringify(retryResult).substring(0, 200)}`);
|
||||
return `RPC-RETRY:HandleCascadeUserInteraction(${typeLower})`;
|
||||
} catch (retryErr: any) {
|
||||
ctx.logToFile(`[APPROVAL-RETRY] ❌ ${retryErr.message?.substring(0, 200)}`);
|
||||
}
|
||||
} else {
|
||||
ctx.logToFile('[APPROVAL] LS not changed — already on correct port or fix unavailable');
|
||||
}
|
||||
} catch (fixErr: any) {
|
||||
ctx.logToFile(`[APPROVAL] fixLSConnection error: ${fixErr.message?.substring(0, 200)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user