So yeah I spent like 2 hours deep dive debugging into this only to discover a bug.
|
private createAgent( |
|
cluster: Cluster | null, |
|
agentOptions: https.AgentOptions, |
|
): https.Agent | SocksProxyAgent | HttpProxyAgent | HttpsProxyAgent { |
|
let agent: https.Agent | SocksProxyAgent | HttpProxyAgent | HttpsProxyAgent; |
|
|
|
if (cluster && cluster.proxyUrl) { |
|
if (cluster.proxyUrl.startsWith('socks')) { |
|
agent = new SocksProxyAgent(cluster.proxyUrl, agentOptions); |
|
} else if (cluster.server.startsWith('https')) { |
|
const httpsProxyAgentOptions: HttpsProxyAgentOptions = agentOptions as HttpsProxyAgentOptions; |
|
httpsProxyAgentOptions.proxy = cluster.proxyUrl; |
|
agent = new HttpsProxyAgent(httpsProxyAgentOptions); |
|
} else if (cluster.server.startsWith('http')) { |
|
const httpProxyAgentOptions: HttpProxyAgentOptions = agentOptions as HttpProxyAgentOptions; |
|
httpProxyAgentOptions.proxy = cluster.proxyUrl; |
|
agent = new HttpProxyAgent(httpProxyAgentOptions); |
|
} else { |
|
throw new Error('Unsupported proxy type'); |
|
} |
|
} else { |
|
agent = new https.Agent(agentOptions); |
|
} |
|
return agent; |
|
} |
more specifically
|
if (cluster && cluster.proxyUrl) { |
|
if (cluster.proxyUrl.startsWith('socks')) { |
|
agent = new SocksProxyAgent(cluster.proxyUrl, agentOptions); |
|
} else if (cluster.server.startsWith('https')) { |
if no proxyUrl is set, then the default will be an HTTPS agent, which does not work with kubectl proxy environments.
So yeah I spent like 2 hours deep dive debugging into this only to discover a bug.
javascript/src/config.ts
Lines 527 to 551 in 3283cb1
more specifically
javascript/src/config.ts
Lines 533 to 536 in 3283cb1
if no
proxyUrlis set, then the default will be an HTTPS agent, which does not work withkubectl proxyenvironments.