Skip to content

Commit eb3c17e

Browse files
[AZureCLIV2] fix timeout error on node20 (#20277)
- Bumped libraries and added keepAlive true to override glabalAgent for node20 because it has default timeout 5sec since node19 - Respectfully handle AggregationError
1 parent 8a06550 commit eb3c17e

File tree

14 files changed

+502
-225
lines changed

14 files changed

+502
-225
lines changed

Tasks/AzureCLIV2/_buildConfigs/Node20/package-lock.json

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

Tasks/AzureCLIV2/_buildConfigs/Node20/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"@types/mocha": "^5.2.7",
2121
"@types/node": "^20.3.1",
2222
"@types/q": "1.0.7",
23-
"azure-devops-node-api": "^12.0.0",
23+
"azure-devops-node-api": "14.0.2",
2424
"azure-pipelines-task-lib": "^4.10.1",
25-
"azure-pipelines-tasks-artifacts-common": "^2.212.0"
25+
"azure-pipelines-tasks-artifacts-common": "2.244.0"
2626
},
2727
"devDependencies": {
2828
"typescript": "5.1.6"

Tasks/AzureCLIV2/azureclitask.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ export class azureclitask {
139139
}
140140
}
141141

142+
// only Aggregation error contains array of errors
143+
if (toolExecutionError.errors) {
144+
// Iterates through array and log errors separately
145+
toolExecutionError.errors.forEach((error) => {
146+
tl.error(error.message, tl.IssueSource.TaskInternal);
147+
});
148+
149+
// fail with main message
150+
tl.setResult(tl.TaskResult.Failed, toolExecutionError.message);
151+
} else {
152+
tl.setResult(tl.TaskResult.Failed, message);
153+
}
154+
142155
tl.setResult(tl.TaskResult.Failed, message);
143156
} else if (exitCode != 0){
144157
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailedWithExitCode", exitCode));
@@ -278,6 +291,13 @@ export class azureclitask {
278291
}
279292

280293
private static async getIdToken(connectedService: string) : Promise<string> {
294+
#if NODE20
295+
// since node19 default node's GlobalAgent has timeout 5sec
296+
// keepAlive is set to true to avoid creating default node's GlobalAgent
297+
const webApiOptions = {
298+
keepAlive: true
299+
}
300+
#endif
281301
const jobId = tl.getVariable("System.JobId");
282302
const planId = tl.getVariable("System.PlanId");
283303
const projectId = tl.getVariable("System.TeamProjectId");
@@ -286,7 +306,11 @@ export class azureclitask {
286306
const token = getSystemAccessToken();
287307

288308
const authHandler = getHandlerFromToken(token);
309+
#if NODE20
310+
const connection = new WebApi(uri, authHandler, webApiOptions);
311+
#else
289312
const connection = new WebApi(uri, authHandler);
313+
#endif
290314
const api: ITaskApi = await connection.getTaskApi();
291315
const response = await api.createOidcToken({}, projectId, hub, planId, jobId, connectedService);
292316
if (response == null) {

Tasks/AzureCLIV2/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"demands": [],
2020
"version": {
2121
"Major": 2,
22-
"Minor": 242,
22+
"Minor": 244,
2323
"Patch": 0
2424
},
2525
"minimumAgentVersion": "2.0.0",

Tasks/AzureCLIV2/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"demands": [],
2020
"version": {
2121
"Major": 2,
22-
"Minor": 242,
22+
"Minor": 244,
2323
"Patch": 0
2424
},
2525
"minimumAgentVersion": "2.0.0",

_generated/AzureCLIV2.versionmap.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|2.242.0
2-
Node20_229_2|2.242.1
1+
Default|2.244.0
2+
Node20_229_2|2.244.1

_generated/AzureCLIV2/azureclitask.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ export class azureclitask {
139139
}
140140
}
141141

142+
// only Aggregation error contains array of errors
143+
if (toolExecutionError.errors) {
144+
// Iterates through array and log errors separately
145+
toolExecutionError.errors.forEach((error) => {
146+
tl.error(error.message, tl.IssueSource.TaskInternal);
147+
});
148+
149+
// fail with main message
150+
tl.setResult(tl.TaskResult.Failed, toolExecutionError.message);
151+
} else {
152+
tl.setResult(tl.TaskResult.Failed, message);
153+
}
154+
142155
tl.setResult(tl.TaskResult.Failed, message);
143156
} else if (exitCode != 0){
144157
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailedWithExitCode", exitCode));

_generated/AzureCLIV2/task.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"demands": [],
2020
"version": {
2121
"Major": 2,
22-
"Minor": 242,
22+
"Minor": 244,
2323
"Patch": 0
2424
},
2525
"minimumAgentVersion": "2.0.0",
@@ -226,7 +226,7 @@
226226
"KeepingAzSessionActiveUnsupportedScheme": "The 'keepAzSessionActive' input might be used only for workload identity federation ARM service connection. The referenced service endpoint auth scheme was unexpected: %s. Change the scheme or remove 'keepAzSessionActive' input."
227227
},
228228
"_buildConfigMapping": {
229-
"Default": "2.242.0",
230-
"Node20_229_2": "2.242.1"
229+
"Default": "2.244.0",
230+
"Node20_229_2": "2.244.1"
231231
}
232232
}

_generated/AzureCLIV2/task.loc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"demands": [],
2020
"version": {
2121
"Major": 2,
22-
"Minor": 242,
22+
"Minor": 244,
2323
"Patch": 0
2424
},
2525
"minimumAgentVersion": "2.0.0",
@@ -226,7 +226,7 @@
226226
"KeepingAzSessionActiveUnsupportedScheme": "ms-resource:loc.messages.KeepingAzSessionActiveUnsupportedScheme"
227227
},
228228
"_buildConfigMapping": {
229-
"Default": "2.242.0",
230-
"Node20_229_2": "2.242.1"
229+
"Default": "2.244.0",
230+
"Node20_229_2": "2.244.1"
231231
}
232232
}

_generated/AzureCLIV2_Node20/azureclitask.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ export class azureclitask {
139139
}
140140
}
141141

142+
// only Aggregation error contains array of errors
143+
if (toolExecutionError.errors) {
144+
// Iterates through array and log errors separately
145+
toolExecutionError.errors.forEach((error) => {
146+
tl.error(error.message, tl.IssueSource.TaskInternal);
147+
});
148+
149+
// fail with main message
150+
tl.setResult(tl.TaskResult.Failed, toolExecutionError.message);
151+
} else {
152+
tl.setResult(tl.TaskResult.Failed, message);
153+
}
154+
142155
tl.setResult(tl.TaskResult.Failed, message);
143156
} else if (exitCode != 0){
144157
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailedWithExitCode", exitCode));
@@ -278,6 +291,11 @@ export class azureclitask {
278291
}
279292

280293
private static async getIdToken(connectedService: string) : Promise<string> {
294+
// since node19 default node's GlobalAgent has timeout 5sec
295+
// keepAlive is set to true to avoid creating default node's GlobalAgent
296+
const webApiOptions = {
297+
keepAlive: true
298+
}
281299
const jobId = tl.getVariable("System.JobId");
282300
const planId = tl.getVariable("System.PlanId");
283301
const projectId = tl.getVariable("System.TeamProjectId");
@@ -286,7 +304,7 @@ export class azureclitask {
286304
const token = getSystemAccessToken();
287305

288306
const authHandler = getHandlerFromToken(token);
289-
const connection = new WebApi(uri, authHandler);
307+
const connection = new WebApi(uri, authHandler, webApiOptions);
290308
const api: ITaskApi = await connection.getTaskApi();
291309
const response = await api.createOidcToken({}, projectId, hub, planId, jobId, connectedService);
292310
if (response == null) {

0 commit comments

Comments
 (0)