Skip to content

Commit c835561

Browse files
Solve 1.93 performance issue (#1432)
* Bump node-fetch-cjs to investigate 1.93 performance issue * Reuse Agent across requests * Don't enable keepAlive, in case this is causing #1428 * Add comments now the workaround has been validated
1 parent a53daf7 commit c835561

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@
18421842
"istextorbinary": "^6.0.0",
18431843
"minimatch": "^9.0.3",
18441844
"node-cmd": "^5.0.0",
1845-
"node-fetch-cjs": "3.1.1",
1845+
"node-fetch-cjs": "^3.3.2",
18461846
"vscode-cache": "^0.3.0",
18471847
"@vscode/debugadapter": "^1.61.0",
18481848
"@vscode/debugprotocol": "^1.61.0",

src/api/index.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface ConnectionSettings {
4343

4444
export class AtelierAPI {
4545
private _config: ConnectionSettings;
46+
private _agent?: httpModule.Agent | httpsModule.Agent;
4647
private namespace: string;
4748
public configName: string;
4849

@@ -303,11 +304,18 @@ export class AtelierAPI {
303304

304305
const proto = this._config.https ? "https" : "http";
305306
const http = this._config.https ? httpsModule : httpModule;
306-
const agent = new http.Agent({
307-
keepAlive: true,
308-
maxSockets: 10,
309-
rejectUnauthorized: https && vscode.workspace.getConfiguration("http").get("proxyStrictSSL"),
310-
});
307+
if (!this._agent) {
308+
this._agent = new http.Agent({
309+
/* VS Code 1.93 adopted a version of vscode-proxy-agent that fixed a failure to pass-through the keepAlive option (see https://github.com/microsoft/vscode/issues/173861 and https://github.com/microsoft/vscode-proxy-agent/commit/4eddc930d4fbc6b88ca5557ea7af07d623d390d6)
310+
* This caused poor performance on some operations by our extension (see https://github.com/intersystems-community/vscode-objectscript/issues/1428)
311+
* Short term solution adopted by PR https://github.com/intersystems-community/vscode-objectscript/pull/1432 is not to enable keepAlive
312+
* We should revisit this in the future - TODO
313+
*/
314+
//keepAlive: true,
315+
//maxSockets: 10,
316+
rejectUnauthorized: https && vscode.workspace.getConfiguration("http").get("proxyStrictSSL"),
317+
});
318+
}
311319

312320
let pathPrefix = this._config.pathPrefix || "";
313321
if (pathPrefix.length && !pathPrefix.startsWith("/")) {
@@ -340,7 +348,7 @@ export class AtelierAPI {
340348
const cookie = await auth;
341349
const response = await fetch(`${proto}://${host}:${port}${path}`, {
342350
method,
343-
agent,
351+
agent: this._agent,
344352
body: body ? (typeof body !== "string" ? JSON.stringify(body) : body) : null,
345353
headers: {
346354
...headers,

0 commit comments

Comments
 (0)