From 298c72219bcc76aa0ff825b77f307013b568fcc5 Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Mon, 24 Jun 2024 15:08:31 +0200 Subject: [PATCH] Module not shared on Windows? --- .../vscode-api-tests/src/singlefolder-tests/proxy.test.ts | 8 ++++---- src/vs/workbench/api/node/proxyResolver.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/proxy.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/proxy.test.ts index 74fa5d181a5..60f100c7c1f 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/proxy.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/proxy.test.ts @@ -8,7 +8,7 @@ import 'mocha'; import { assertNoRpc } from '../utils'; import { pki } from 'node-forge'; import { AddressInfo } from 'net'; -import { resetCaches, testCertificates } from '@vscode/proxy-agent'; +import { resetCaches } from '@vscode/proxy-agent'; suite('vscode API - network proxy support', () => { @@ -52,8 +52,8 @@ suite('vscode API - network proxy support', () => { rejectPort(err); }); - // Using `testCertificates` shared between proxyResolver.ts and proxy.test.ts. - testCertificates.splice(0, testCertificates.length, certPEM); + // Using https.globalAgent because it is shared with proxyResolver.ts and mutable. + (https.globalAgent as any).testCertificates = [certPEM]; resetCaches(); try { @@ -69,7 +69,7 @@ suite('vscode API - network proxy support', () => { .on('error', reject); }); } finally { - testCertificates.splice(0, testCertificates.length); + delete (https.globalAgent as any).testCertificates; resetCaches(); server.close(); } diff --git a/src/vs/workbench/api/node/proxyResolver.ts b/src/vs/workbench/api/node/proxyResolver.ts index 6cb6349d172..f2854500083 100644 --- a/src/vs/workbench/api/node/proxyResolver.ts +++ b/src/vs/workbench/api/node/proxyResolver.ts @@ -16,7 +16,7 @@ import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionS import { URI } from 'vs/base/common/uri'; import { ILogService, LogLevel as LogServiceLevel } from 'vs/platform/log/common/log'; import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; -import { LogLevel, createHttpPatch, createProxyResolver, createTlsPatch, ProxySupportSetting, ProxyAgentParams, createNetPatch, loadSystemCertificates, testCertificates } from '@vscode/proxy-agent'; +import { LogLevel, createHttpPatch, createProxyResolver, createTlsPatch, ProxySupportSetting, ProxyAgentParams, createNetPatch, loadSystemCertificates } from '@vscode/proxy-agent'; const systemCertificatesV2Default = false; @@ -67,10 +67,10 @@ export function connectProxyResolver( certs.then(certs => extHostLogService.trace('ProxyResolver#loadAdditionalCertificates: Loaded certificates from main process', certs.length)); promises.push(certs); } - // Using `testCertificates` shared between proxyResolver.ts and proxy.test.ts. - if (initData.environment.extensionTestsLocationURI && testCertificates.length) { + // Using https.globalAgent because it is shared with proxy.test.ts and mutable. + if (initData.environment.extensionTestsLocationURI && (https.globalAgent as any).testCertificates?.length) { extHostLogService.trace('ProxyResolver#loadAdditionalCertificates: Loading test certificates'); - promises.push(Promise.resolve(testCertificates)); + promises.push(Promise.resolve((https.globalAgent as any).testCertificates as string[])); } return (await Promise.all(promises)).flat(); },