Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ import { Heap } from "./heap"
import { CpuProfile } from "./cpu-profile"
import { ShutdownDeadline } from "./shutdown-deadline"

// Keep requests to the local service off any proxy. Bun reads lowercase `no_proxy` alone whenever it is set, so both
// spellings get the same merged list.
const noProxy = [
...new Set(
[process.env.NO_PROXY, process.env.no_proxy, "127.0.0.1,localhost,::1"].flatMap((value) =>
(value ?? "").split(",").flatMap((entry) => entry.trim() || []),
),
),
].join(",")

process.env.NO_PROXY = noProxy
process.env.no_proxy = noProxy

ensurePluginRuntime()

if (process.env.OPENCODE_SSH_ASKPASS_PORT) {
Expand Down
22 changes: 10 additions & 12 deletions packages/desktop/src/main/lifecycle/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,16 @@ const loadSystemCertificates = Effect.try({
catch: (error) => error,
}).pipe(Effect.catch((error) => Effect.logWarning("failed to load system certificates", { error })))

// Bun reads lowercase `no_proxy` alone whenever it is set, so both spellings get the same merged list.
function ensureLoopbackNoProxy() {
const loopback = ["127.0.0.1", "localhost", "::1"]
const noProxy = [
...new Set(
[process.env.NO_PROXY, process.env.no_proxy, "127.0.0.1,localhost,::1"].flatMap((value) =>
(value ?? "").split(",").flatMap((entry) => entry.trim() || []),
),
),
].join(",")

;["NO_PROXY", "no_proxy"].forEach((key) => {
const items = (process.env[key] ?? "")
.split(",")
.map((value) => value.trim())
.filter(Boolean)

loopback.forEach((host) => {
if (!items.some((value) => value.toLowerCase() === host)) items.push(host)
})
process.env[key] = items.join(",")
})
process.env.NO_PROXY = noProxy
process.env.no_proxy = noProxy
}
Loading