fix(ext): v0.5.8 false positive zombie socket disconnect bug resolve (timestamp replace setTimeout)

This commit is contained in:
Variet Worker
2026-03-24 07:00:43 +09:00
parent ecebec3906
commit f13bcc871c
12 changed files with 141 additions and 73 deletions

View File

@@ -106,8 +106,8 @@ function detectProjectName() {
const cwd = folders[0].uri.fsPath;
try {
const remoteUrl = cp.execSync('git remote get-url origin', {
cwd, encoding: 'utf-8', timeout: 3000
}).trim();
cwd, encoding: 'utf-8', timeout: 2000, windowsHide: true, stdio: ['ignore', 'pipe', 'ignore']
}).toString().trim();
const match = remoteUrl.match(/\/([^\/]+?)(?:\.git)?$/);
if (match && match[1]) {
return match[1].toLowerCase().replace(/[\s\-]+/g, '_');
@@ -278,7 +278,7 @@ async function fixLSConnection() {
try {
const psScript = `Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -match 'language_server' -and $_.CommandLine -match 'csrf_token' } | ForEach-Object { $_.ProcessId.ToString() + '|' + $_.CommandLine }`;
const encoded = Buffer.from(psScript, 'utf16le').toString('base64');
const result = await execAsync(`powershell.exe -NoProfile -EncodedCommand ${encoded}`, { encoding: 'utf8', timeout: 15000, windowsHide: true });
const result = await execAsync(`powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand ${encoded}`, { encoding: 'utf8', timeout: 5000, windowsHide: true });
output = result.stdout;
}
catch (psErr) {
@@ -330,12 +330,14 @@ async function fixLSConnection() {
// Find ConnectRPC port via netstat (same as SDK logic)
let netstatOutput;
try {
const result = await execAsync(`netstat -aon | findstr "LISTENING" | findstr "${pid}"`, { encoding: 'utf8', timeout: 5000, windowsHide: true });
netstatOutput = result.stdout;
const result = await execAsync(`netstat -aon`, { encoding: 'utf8', timeout: 4000, windowsHide: true });
netstatOutput = result.stdout.split('\n')
.filter((l) => l.includes('LISTENING') && l.includes(pid.toString()))
.join('\n');
}
catch {
catch (err) {
// Netstat failed — try extension_server_port as fallback
logToFile(`[LS-FIX] netstat failed, using ext_port=${extPort} for PID=${pid}`);
logToFile(`[LS-FIX] netstat failed: ${err.message.substring(0, 80)}, using ext_port=${extPort} for PID=${pid}`);
sdk.ls.setConnection(extPort, csrfToken, false);
logToFile(`[LS-FIX] ✅ Reconnected to correct LS: port=${extPort} hint="${hint}" PID=${pid}`);
return true;
@@ -540,14 +542,25 @@ async function activate(context) {
get lastPendingStepIndex() { return (0, step_probe_1.getStepProbeContext)().lastPendingStepIndex; },
};
const bridgePort = await (0, http_bridge_1.startHttpBridge)(httpBridgeCtx, sdk);
let localPort = bridgePort;
if (bridgePort) {
await (0, html_patcher_1.setupApprovalObserver)(sdk, bridgePort, logToFile);
try {
const externalUri = await vscode.env.asExternalUri(vscode.Uri.parse(`http://127.0.0.1:${bridgePort}`));
const match = externalUri.authority.match(/:(\d+)$/);
if (match) {
localPort = parseInt(match[1], 10);
}
}
catch (e) {
logToFile(`[OBSERVER] asExternalUri failed: ${e.message}`);
}
await (0, html_patcher_1.setupApprovalObserver)(sdk, localPort, logToFile);
}
else {
logToFile('[OBSERVER] HTTP bridge failed — skipping observer setup');
}
statusBar.text = '$(check) Bridge';
statusBar.tooltip = `Gravity Bridge: ${projectName} (POLL + Observer active)`;
statusBar.tooltip = `Gravity Bridge Control | port:${localPort} | project:${projectName}`;
// Register SDK-powered commands
context.subscriptions.push(vscode.commands.registerCommand('gravityBridge.approve', async () => {
try {

File diff suppressed because one or more lines are too long