fix: tighten server update check handling (#694)

Refine server update-check flow in runtime endpoints
Improve package-manager update detection consistency
This commit is contained in:
Bohdan Triapitsyn
2026-03-17 13:25:55 +02:00
committed by GitHub
parent 3123de5f43
commit 74ef18dd4f
2 changed files with 8 additions and 19 deletions
+2 -17
View File
@@ -7782,28 +7782,13 @@ async function main(options = {}) {
if (value.includes('mobi') || value.includes('android') || value.includes('iphone')) return 'mobile';
return 'desktop';
};
const inferArch = (ua) => {
const value = (ua || '').toLowerCase();
if (!value) return 'unknown';
if (value.includes('aarch64') || value.includes('arm64') || value.includes(' arm;') || value.includes('armv')) return 'arm64';
if (value.includes('x86_64') || value.includes('x64') || value.includes('amd64') || value.includes('win64') || value.includes('x86-64')) return 'x64';
return 'unknown';
};
const inferPlatform = (ua) => {
const value = (ua || '').toLowerCase();
if (!value) return undefined;
if (value.includes('mac os') || value.includes('macintosh') || value.includes('darwin')) return 'macos';
if (value.includes('windows') || value.includes('win32') || value.includes('win64')) return 'windows';
if (value.includes('linux') || value.includes('x11')) return 'linux';
return 'web';
};
const userAgent = typeof req.headers['user-agent'] === 'string' ? req.headers['user-agent'] : '';
const updateInfo = await checkForUpdates({
appType: parseString(req.query.appType),
deviceClass: parseString(req.query.deviceClass) || inferDeviceClass(userAgent),
platform: parseString(req.query.platform) || inferPlatform(userAgent),
arch: parseString(req.query.arch) || inferArch(userAgent),
platform: parseString(req.query.platform),
arch: parseString(req.query.arch),
instanceMode: parseString(req.query.instanceMode),
currentVersion: parseString(req.query.currentVersion),
reportUsage: parseReportUsage(parseString(req.query.reportUsage)),
+6 -2
View File
@@ -86,11 +86,15 @@ function normalizeArch(value) {
async function checkForUpdatesFromApi(currentVersion, options = {}) {
try {
const appType = normalizeAppType(options.appType);
const hostPlatform = mapPlatform(process.platform);
const hostArch = mapArch(process.arch);
const platform = appType === 'vscode' ? normalizePlatform(options.platform) : hostPlatform;
const arch = appType === 'vscode' ? normalizeArch(options.arch) : hostArch;
const payload = {
appType,
deviceClass: normalizeDeviceClass(options.deviceClass),
platform: normalizePlatform(options.platform),
arch: normalizeArch(options.arch),
platform,
arch,
channel: 'stable',
currentVersion,
installId: getOrCreateInstallId(appType),