{"record":{"id":"6acb44e187580654","repo":"usebruno/bruno","slug":"macos-proxy-detection-failed-error-instanceof-e","errorCode":null,"errorMessage":"macOS proxy detection failed: ${error instanceof Error ? error.message : String(error)}","messagePattern":"macOS proxy detection failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/network/system-proxy/utils/macos.ts","lineNumber":17,"sourceCode":"import { ExecFileOptions } from 'node:child_process';\nimport { ProxyConfiguration, ProxyResolver } from '../types';\nimport { normalizeProxyUrl, normalizeNoProxy, execFileAsync } from './common';\n\nexport class MacOSProxyResolver implements ProxyResolver {\n  async detect(opts?: { timeoutMs?: number }): Promise<ProxyConfiguration> {\n    const timeoutMs = opts?.timeoutMs ?? 10000;\n    const execOpts: ExecFileOptions = {\n      timeout: timeoutMs,\n      maxBuffer: 1024 * 1024\n    };\n\n    try {\n      const { stdout } = await execFileAsync('scutil', ['--proxy'], execOpts);\n      return this.parseScutilOutput(stdout);\n    } catch (error) {\n      throw new Error(`macOS proxy detection failed: ${error instanceof Error ? error.message : String(error)}`);\n    }\n  }\n\n  private parseScutilOutput(output: string): ProxyConfiguration {\n    if (typeof output !== 'string') {\n      throw new Error('Invalid scutil --proxy output');\n    }\n\n    const cleanLines = output.split('\\n')\n      .map((line) => line.trim())\n      .filter((line) => line.length > 0);\n\n    const dictStart = cleanLines.findIndex((line) => line.includes('<dictionary>'));\n    if (dictStart === -1) {\n      throw new Error('Invalid scutil --proxy output format');\n    }\n    const config = this.parseConfiguration(cleanLines, dictStart);\n    return this.buildProxyConfiguration(config);","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/network/system-proxy/utils/macos.ts#L1-L35","documentation":"MacOSProxyResolver.detect runs `scutil --proxy` and parses its output; any rejection from execFile or thrown parse error is caught and re-wrapped with the 'macOS proxy detection failed:' prefix, keeping the original message.","triggerScenarios":"scutil is missing/not executable, the command times out, or parseScutilOutput raises (invalid output / invalid format) on the returned stdout.","commonSituations":"Sandboxed/locked-down macOS where scutil is restricted; very slow system under load hitting the 10s default timeout; non-English locale producing unexpected scutil formatting; running in a non-macOS environment that nonetheless hits the darwin branch.","solutions":["Check the suffix message: 'Invalid scutil --proxy output format' => parse issue; spawn ENOENT => scutil missing; ETIMEDOUT => raise commandTimeoutMs.","Run `scutil --proxy` manually in Terminal and compare output shape to the parser's expectations.","Pass a larger timeoutMs to SystemProxyResolver constructor ({ commandTimeoutMs }) if the call is slow.","Use environment-variable proxies or explicit proxy config as a fallback."],"exampleFix":"// before\nconst resolver = new MacOSProxyResolver();\nawait resolver.detect(); // default 10s timeout\n\n// after\nconst resolver = new MacOSProxyResolver();\nawait resolver.detect({ timeoutMs: 30000 });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return await macResolver.detect({ timeoutMs: 30000 }); } catch (e) { if (/macOS proxy detection failed/.test(e.message)) return DIRECT_CONFIG; throw e; }","preventionTips":["Tune commandTimeoutMs to the host's responsiveness.","Verify `scutil --proxy` works in a terminal before relying on detection.","Fall back to environment-variable proxies on locked-down macOS."],"tags":["proxy","macos","system-proxy","scutil"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}