{"record":{"id":"4fd2f66826c3e006","repo":"docmirror/dev-sidecar","slug":"windows","errorCode":null,"errorMessage":"设置windows系统代理失败：执行 ","messagePattern":"设置windows系统代理失败：执行 ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/src/shell/scripts/set-system-proxy/index.js","lineNumber":475,"sourceCode":"      loadConfig()\n\n      log.info('开始设置windows系统代理:', ip, port, setEnv)\n\n      // https\n      let proxyAddr = `https=http://${ip}:${port}`\n      // http\n      if (config.get().proxy.proxyHttp) {\n        proxyAddr = `http=http://${ip}:${port - 1};${proxyAddr}`\n      }\n\n      // 读取排除域名\n      const excludeIpStr = getProxyExcludeIpStr(';')\n      // 设置代理，同时设置排除域名\n      try {\n        require('@starknt/sysproxy').triggerManualProxyByUrl(true, proxyAddr, excludeIpStr, true)\n        log.info(`设置windows系统代理成功: ${proxyAddr} ......(省略排除IP列表)`)\n      } catch (e1) {\n        log.warn('设置windows系统代理失败：执行 `@starknt/sysproxy` 失败，现尝试通过执行 `sysproxy.exe global ...` 来设置系统代理！\\r\\n捕获的异常:', e1)\n\n        const proxyPath = extraPath.getProxyExePath()\n        const execFun = 'global'\n        try {\n          await execFile(proxyPath, [execFun, proxyAddr, excludeIpStr])\n          log.info(`设置windows系统代理成功，执行的命令：${proxyPath} ${execFun} ${proxyAddr} ......(省略排除IP列表)`)\n        } catch (e2) {\n          log.error(`设置windows系统代理失败，执行的命令：${proxyPath} ${execFun} ${proxyAddr} ......(省略排除IP列表), error:`, e2)\n          throw e1 // 将上面的异常抛出\n        }\n      }\n\n      if (setEnv) {\n        // 设置全局代理所需的环境变量\n        try {\n          await exec(`echo '设置环境变量 HTTPS_PROXY${config.get().proxy.proxyHttp ? '、HTTP_PROXY' : ''}${setCaBundle ? '、REQUEST_CA_BUNDLE' : ''}'`)\n\n          log.info(`开启系统代理的同时设置环境变量：HTTPS_PROXY = \"http://${ip}:${port}/\"`)","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/core/src/shell/scripts/set-system-proxy/index.js#L457-L493","documentation":"Warning logged in the Windows system-proxy setter when the primary mechanism, the native module `@starknt/sysproxy` (triggerManualProxyByUrl), throws. The code logs this warning and retries via the bundled `sysproxy.exe global <addr> <exclude>` executable. If the exe also fails (e2), the original sysproxy exception (e1) is re-thrown and the proxy setup fails.","triggerScenarios":"Called during executor.windows() on enabling the system proxy. Triggers: @starknt/sysproxy native binding fails to load or call (wrong Node ABI/electron rebuild mismatch, missing DLL, unsupported Windows), or WinHTTP/WinINET call rejected (WinInet not available in service session).","commonSituations":"Electron version upgrades breaking the prebuilt native module (NODE_MODULE_VERSION mismatch); running from a Windows Service/session 0 where user proxy settings are inaccessible; antivirus blocking sysproxy.exe; the bundled sysproxy.exe missing from the packaged app.","solutions":["Check the logged captured exception (e1) for NODE_MODULE_VERSION/ABI mismatch; run `pnpm rebuild @starknt/sysproxy` or reinstall node_modules so the native module matches the running Node/Electron","Confirm sysproxy.exe exists next to the app (extraPath.getProxyExePath()) and is not blocked by antivirus; re-run the installer if missing","Run the app in a normal interactive user session (not a service), and verify manual proxy works: Settings > Network > Proxy should show the address after enabling","If the native module remains incompatible with your platform, set the Windows proxy manually or disable automatic system-proxy in DevSidecar config"],"exampleFix":"// before (native module ABI mismatch after Electron upgrade)\nrequire('@starknt/sysproxy').triggerManualProxyByUrl(true, proxyAddr, excludeIpStr, true)\n// Error: NODE_MODULE_VERSION mismatch\n\n// after — rebuild native deps against the current runtime\npnpm install\npnpm rebuild @starknt/sysproxy","handlingStrategy":"try-catch","validationCode":"function sysproxyModuleUsable() {\n  try {\n    const sysproxy = require('@starknt/sysproxy')\n    return typeof sysproxy.triggerManualProxyByUrl === 'function'\n  } catch (e) {\n    console.warn('@starknt/sysproxy unavailable:', e.message)\n    return false\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await DevSidecar.api.config.set('proxy.enable', true)\n} catch (e) {\n  console.error('Windows system proxy could not be set (both sysproxy paths failed):', e.message)\n  // fallback: set proxy manually via Settings > Network > Proxy\n}","preventionTips":["Rebuild native modules after every Node/Electron version change (pnpm rebuild)","Keep sysproxy.exe present and allowlisted in antivirus next to the app","Run the app in an interactive user session, not as a Windows service","Verify proxy takes effect in Settings > Network > Proxy after enabling"],"tags":["windows","sysproxy","native-module","fallback"],"backgroundTag":"native-module-load-failed","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}