fix(ext): v0.5.8 false positive zombie socket disconnect bug resolve (timestamp replace setTimeout)
This commit is contained in:
@@ -71,8 +71,8 @@ function detectProjectName(): string {
|
||||
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, '_');
|
||||
@@ -233,8 +233,8 @@ export async function fixLSConnection(): Promise<boolean> {
|
||||
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 }
|
||||
`powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand ${encoded}`,
|
||||
{ encoding: 'utf8', timeout: 5000, windowsHide: true }
|
||||
);
|
||||
output = result.stdout;
|
||||
} catch (psErr: any) {
|
||||
@@ -292,13 +292,15 @@ export async function fixLSConnection(): Promise<boolean> {
|
||||
let netstatOutput: string;
|
||||
try {
|
||||
const result = await execAsync(
|
||||
`netstat -aon | findstr "LISTENING" | findstr "${pid}"`,
|
||||
{ encoding: 'utf8', timeout: 5000, windowsHide: true }
|
||||
`netstat -aon`,
|
||||
{ encoding: 'utf8', timeout: 4000, windowsHide: true }
|
||||
);
|
||||
netstatOutput = result.stdout;
|
||||
} catch {
|
||||
netstatOutput = result.stdout.split('\n')
|
||||
.filter((l: string) => l.includes('LISTENING') && l.includes(pid.toString()))
|
||||
.join('\n');
|
||||
} catch (err: any) {
|
||||
// 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;
|
||||
@@ -526,13 +528,21 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
get lastPendingStepIndex() { return getStepProbeContext().lastPendingStepIndex; },
|
||||
};
|
||||
const bridgePort = await startHttpBridge(httpBridgeCtx, sdk);
|
||||
let localPort = bridgePort;
|
||||
if (bridgePort) {
|
||||
await 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: any) {
|
||||
logToFile(`[OBSERVER] asExternalUri failed: ${e.message}`);
|
||||
}
|
||||
await 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(
|
||||
|
||||
Reference in New Issue
Block a user