fix: LS ConnectRPC use HTTPS when detected, not port heuristic

This commit is contained in:
2026-03-07 18:31:13 +09:00
parent 91b3a7ef20
commit f2ed431aa5
4 changed files with 21 additions and 5 deletions

View File

@@ -122,6 +122,7 @@ function activate(context) {
let lsPort = null;
let lsCsrf = '';
let lsPid = null;
let lsUseTls = false; // track detected protocol
let lastStepIndex = {}; // cascadeId → last known step index
async function discoverLS() {
return new Promise((resolve) => {
@@ -210,8 +211,15 @@ function activate(context) {
let data = '';
res.on('data', (chunk) => { data += chunk; });
res.on('end', () => {
// Any response (even error) means ConnectRPC is here
console.log(`Gravity Bridge: [LS] port ${port} (${useTls ? 'https' : 'http'}) status=${res.statusCode} body=${data.substring(0, 200)}`);
// If HTTP got "HTTPS server" response, retry with HTTPS
if (!useTls && data.includes('HTTPS server')) {
tryProto(https, true);
return;
}
if (res.statusCode !== 404) {
lsUseTls = useTls; // remember which protocol worked
}
resolve(res.statusCode !== 404);
});
});
@@ -238,7 +246,7 @@ function activate(context) {
return new Promise((resolve) => {
const http = require('http');
const https = require('https');
const proto = lsPort > 40000 ? https : http; // heuristic
const proto = lsUseTls ? https : http; // use detected protocol
const body = JSON.stringify(payload);
const req = proto.request({
hostname: '127.0.0.1',