Skip to content

Commit 4ed4254

Browse files
authored
adopt vscode/proxy-agent (#116)
1 parent 7b92da7 commit 4ed4254

File tree

10 files changed

+199
-16
lines changed

10 files changed

+199
-16
lines changed

package-lock-overrides/sagemaker.series/remote/package-lock.json

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock-overrides/web-embedded-with-terminal.series/remote/package-lock.json

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock-overrides/web-embedded.series/remote/package-lock.json

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock-overrides/web-server.series/remote/package-lock.json

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
Index: third-party-src/src/bootstrap-fork.ts
2+
===================================================================
3+
--- third-party-src.orig/src/bootstrap-fork.ts
4+
+++ third-party-src/src/bootstrap-fork.ts
5+
@@ -123,7 +123,7 @@ function pipeLoggingToParent(): void {
6+
7+
Object.defineProperty(stream, 'write', {
8+
set: () => { },
9+
- get: () => (chunk: string | Buffer | Uint8Array, encoding: BufferEncoding | undefined, callback: ((err?: Error | undefined) => void) | undefined) => {
10+
+ get: () => (chunk: string | Buffer | Uint8Array, encoding: BufferEncoding | undefined, callback: ((err?: Error | null) => void) | undefined) => {
11+
buf += chunk.toString(encoding);
12+
const eol = buf.length > MAX_STREAM_BUFFER_LENGTH ? buf.length : buf.lastIndexOf('\n');
13+
if (eol !== -1) {
14+
Index: third-party-src/src/vs/platform/environment/test/node/nativeModules.integrationTest.ts
15+
===================================================================
16+
--- third-party-src.orig/src/vs/platform/environment/test/node/nativeModules.integrationTest.ts
17+
+++ third-party-src/src/vs/platform/environment/test/node/nativeModules.integrationTest.ts
18+
@@ -120,6 +120,7 @@ flakySuite('Native Modules (all platforms)', () => {
19+
const proxyAgent = await import('@vscode/proxy-agent');
20+
// This call will load `@vscode/proxy-agent` which is a native module that we want to test on Windows
21+
const windowsCerts = await proxyAgent.loadSystemCertificates({
22+
+ loadSystemCertificatesFromNode: () => undefined,
23+
log: {
24+
trace: () => { },
25+
debug: () => { },
26+
Index: third-party-src/src/vs/platform/request/common/request.ts
27+
===================================================================
28+
--- third-party-src.orig/src/vs/platform/request/common/request.ts
29+
+++ third-party-src/src/vs/platform/request/common/request.ts
30+
@@ -146,8 +146,10 @@ export const USER_LOCAL_AND_REMOTE_SETTINGS = [
31+
'http.proxyAuthorization',
32+
'http.proxySupport',
33+
'http.systemCertificates',
34+
+ 'http.systemCertificatesNode',
35+
'http.experimental.systemCertificatesV2',
36+
'http.fetchAdditionalSupport',
37+
+ 'http.experimental.networkInterfaceCheckInterval',
38+
];
39+
40+
let proxyConfiguration: IConfigurationNode[] = [];
41+
@@ -249,6 +251,13 @@ function registerProxyConfigurations(useHostProxy = true, useHostProxyDefault =
42+
markdownDescription: localize('systemCertificates', "Controls whether CA certificates should be loaded from the OS. On Windows and macOS, a reload of the window is required after turning this off. When during [remote development](https://aka.ms/vscode-remote) the {0} setting is disabled this setting can be configured in the local and the remote settings separately.", '`#http.useLocalProxyConfiguration#`'),
43+
restricted: true
44+
},
45+
+ 'http.systemCertificatesNode': {
46+
+ type: 'boolean',
47+
+ tags: ['experimental'],
48+
+ default: false,
49+
+ markdownDescription: localize('systemCertificatesNode', "Controls whether system certificates should be loaded using Node.js built-in support. Reload the window after changing this setting. When during [remote development](https://aka.ms/vscode-remote) the {0} setting is disabled this setting can be configured in the local and the remote settings separately.", '`#http.useLocalProxyConfiguration#`'),
50+
+ restricted: true
51+
+ },
52+
'http.experimental.systemCertificatesV2': {
53+
type: 'boolean',
54+
tags: ['experimental'],
55+
@@ -261,6 +270,14 @@ function registerProxyConfigurations(useHostProxy = true, useHostProxyDefault =
56+
default: true,
57+
markdownDescription: localize('fetchAdditionalSupport', "Controls whether Node.js' fetch implementation should be extended with additional support. Currently proxy support ({1}) and system certificates ({2}) are added when the corresponding settings are enabled. When during [remote development](https://aka.ms/vscode-remote) the {0} setting is disabled this setting can be configured in the local and the remote settings separately.", '`#http.useLocalProxyConfiguration#`', '`#http.proxySupport#`', '`#http.systemCertificates#`'),
58+
restricted: true
59+
+ },
60+
+ 'http.experimental.networkInterfaceCheckInterval': {
61+
+ type: 'number',
62+
+ default: 300,
63+
+ minimum: -1,
64+
+ tags: ['experimental'],
65+
+ markdownDescription: localize('networkInterfaceCheckInterval', "Controls the interval in seconds for checking network interface changes to invalidate the proxy cache. Set to -1 to disable. When during [remote development](https://aka.ms/vscode-remote) the {0} setting is disabled this setting can be configured in the local and the remote settings separately.", '`#http.useLocalProxyConfiguration#`'),
66+
+ restricted: true
67+
}
68+
}
69+
}
70+
Index: third-party-src/src/vs/platform/request/node/requestService.ts
71+
===================================================================
72+
--- third-party-src.orig/src/vs/platform/request/node/requestService.ts
73+
+++ third-party-src/src/vs/platform/request/node/requestService.ts
74+
@@ -119,15 +119,18 @@ export class RequestService extends AbstractRequestService implements IRequestSe
75+
76+
async loadCertificates(): Promise<string[]> {
77+
const proxyAgent = await import('@vscode/proxy-agent');
78+
- return proxyAgent.loadSystemCertificates({ log: this.logService });
79+
+ return proxyAgent.loadSystemCertificates({
80+
+ loadSystemCertificatesFromNode: () => this.getConfigValue<boolean>('http.systemCertificatesNode', false),
81+
+ log: this.logService,
82+
+ });
83+
}
84+
85+
- private getConfigValue<T>(key: string): T | undefined {
86+
+ private getConfigValue<T>(key: string, fallback?: T): T | undefined {
87+
if (this.machine === 'remote') {
88+
return this.configurationService.getValue<T>(key);
89+
}
90+
const values = this.configurationService.inspect<T>(key);
91+
- return values.userLocalValue || values.defaultValue;
92+
+ return values.userLocalValue ?? values.defaultValue ?? fallback;
93+
}
94+
}
95+
96+
Index: third-party-src/src/vs/workbench/api/node/extHostConsoleForwarder.ts
97+
===================================================================
98+
--- third-party-src.orig/src/vs/workbench/api/node/extHostConsoleForwarder.ts
99+
+++ third-party-src/src/vs/workbench/api/node/extHostConsoleForwarder.ts
100+
@@ -47,7 +47,7 @@ export class ExtHostConsoleForwarder extends AbstractExtHostConsoleForwarder {
101+
102+
Object.defineProperty(stream, 'write', {
103+
set: () => { },
104+
- get: () => (chunk: Uint8Array | string, encoding?: BufferEncoding, callback?: (err?: Error) => void) => {
105+
+ get: () => (chunk: Uint8Array | string, encoding?: BufferEncoding, callback?: (err?: Error | null) => void) => {
106+
if (!this._isMakingConsoleCall) {
107+
buf += (chunk as any).toString(encoding);
108+
const eol = buf.length > MAX_STREAM_BUFFER_LENGTH ? buf.length : buf.lastIndexOf('\n');
109+
Index: third-party-src/src/vs/workbench/api/node/proxyResolver.ts
110+
===================================================================
111+
--- third-party-src.orig/src/vs/workbench/api/node/proxyResolver.ts
112+
+++ third-party-src/src/vs/workbench/api/node/proxyResolver.ts
113+
@@ -53,6 +53,7 @@ export function connectProxyResolver(
114+
isAdditionalFetchSupportEnabled: () => getExtHostConfigValue<boolean>(configProvider, isRemote, 'http.fetchAdditionalSupport', true),
115+
addCertificatesV1: () => certSettingV1(configProvider, isRemote),
116+
addCertificatesV2: () => certSettingV2(configProvider, isRemote),
117+
+ loadSystemCertificatesFromNode: () => getExtHostConfigValue<boolean>(configProvider, isRemote, 'http.systemCertificatesNode', false),
118+
log: extHostLogService,
119+
getLogLevel: () => {
120+
const level = extHostLogService.getLevel();
121+
@@ -72,16 +73,31 @@ export function connectProxyResolver(
122+
},
123+
proxyResolveTelemetry: () => { },
124+
isUseHostProxyEnabled,
125+
+ getNetworkInterfaceCheckInterval: () => {
126+
+ const intervalSeconds = getExtHostConfigValue<number>(configProvider, isRemote, 'http.experimental.networkInterfaceCheckInterval', 300);
127+
+ return intervalSeconds * 1000;
128+
+ },
129+
loadAdditionalCertificates: async () => {
130+
+ const useNodeSystemCerts = getExtHostConfigValue<boolean>(configProvider, isRemote, 'http.systemCertificatesNode', false);
131+
const promises: Promise<string[]>[] = [];
132+
- if (initData.remote.isRemote) {
133+
- promises.push(loadSystemCertificates({ log: extHostLogService }));
134+
+ if (isRemote) {
135+
+ promises.push(loadSystemCertificates({
136+
+ loadSystemCertificatesFromNode: () => useNodeSystemCerts,
137+
+ log: extHostLogService,
138+
+ }));
139+
}
140+
if (loadLocalCertificates) {
141+
- extHostLogService.trace('ProxyResolver#loadAdditionalCertificates: Loading certificates from main process');
142+
- const certs = extHostWorkspace.loadCertificates(); // Loading from main process to share cache.
143+
- certs.then(certs => extHostLogService.trace('ProxyResolver#loadAdditionalCertificates: Loaded certificates from main process', certs.length));
144+
- promises.push(certs);
145+
+ if (!isRemote && useNodeSystemCerts) {
146+
+ promises.push(loadSystemCertificates({
147+
+ loadSystemCertificatesFromNode: () => useNodeSystemCerts,
148+
+ log: extHostLogService,
149+
+ }));
150+
+ } else {
151+
+ extHostLogService.trace('ProxyResolver#loadAdditionalCertificates: Loading certificates from main process');
152+
+ const certs = extHostWorkspace.loadCertificates(); // Loading from main process to share cache.
153+
+ certs.then(certs => extHostLogService.trace('ProxyResolver#loadAdditionalCertificates: Loaded certificates from main process', certs.length));
154+
+ promises.push(certs);
155+
+ }
156+
}
157+
// Using https.globalAgent because it is shared with proxy.test.ts and mutable.
158+
if (initData.environment.extensionTestsLocationURI && (https.globalAgent as any).testCertificates?.length) {

patches/common/build.diff

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ Index: code-editor-src/remote/package.json
8686
===================================================================
8787
--- code-editor-src.orig/remote/package.json
8888
+++ code-editor-src/remote/package.json
89+
@@ -8,7 +8,7 @@
90+
"@parcel/watcher": "2.5.1",
91+
"@vscode/deviceid": "^0.1.1",
92+
"@vscode/iconv-lite-umd": "0.7.0",
93+
- "@vscode/proxy-agent": "^0.32.0",
94+
+ "@vscode/proxy-agent": "^0.37.0",
95+
"@vscode/ripgrep": "^1.15.11",
96+
"@vscode/spdlog": "^0.15.2",
97+
"@vscode/tree-sitter-wasm": "^0.1.4",
8998
@@ -29,7 +29,6 @@
9099
"http-proxy-agent": "^7.0.0",
91100
"https-proxy-agent": "^7.0.2",

patches/sagemaker.series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ common/proposed-api.diff
1717
common/build.diff
1818
common/integration.diff
1919
common/replace-gulp-untar.diff
20+
common/adopt-new-proxy-agent.diff
2021
web-server/suppress-known-errors-build-integration.diff
2122
web-server/local-storage.diff
2223
web-server/base-path.diff

patches/web-embedded-with-terminal.series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ common/proposed-api.diff
1717
common/build.diff
1818
common/integration.diff
1919
common/replace-gulp-untar.diff
20+
common/adopt-new-proxy-agent.diff
2021
web-embedded/readd-workbench.diff
2122
web-embedded/suppress-known-errors-build-integration.diff
2223
web-embedded/disable-built-in-walkthroughs-from-c.diff

patches/web-embedded.series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ common/proposed-api.diff
1717
common/build.diff
1818
common/integration.diff
1919
common/replace-gulp-untar.diff
20+
common/adopt-new-proxy-agent.diff
2021
web-embedded/readd-workbench.diff
2122
web-embedded/suppress-known-errors-build-integration.diff
2223
web-embedded/disable-built-in-walkthroughs-from-c.diff

patches/web-server.series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ common/proposed-api.diff
1717
common/build.diff
1818
common/integration.diff
1919
common/replace-gulp-untar.diff
20+
common/adopt-new-proxy-agent.diff
2021
web-server/suppress-known-errors-build-integration.diff
2122
web-server/local-storage.diff
2223
web-server/base-path.diff

0 commit comments

Comments
 (0)