Skip to content

Commit a303ba1

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

File tree

14 files changed

+403
-128
lines changed

14 files changed

+403
-128
lines changed

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

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

Tasks/AzureCLIV1/_buildConfigs/Node20/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
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"
2525
},
2626
"devDependencies": {

Tasks/AzureCLIV1/azureclitask.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@ export class azureclitask {
123123
}
124124
}
125125

126-
tl.setResult(tl.TaskResult.Failed, message);
126+
// only Aggregation error contains array of errors
127+
if (toolExecutionError.errors) {
128+
// Iterates through array and log errors separately
129+
toolExecutionError.errors.forEach((error) => {
130+
tl.error(error.message, tl.IssueSource.TaskInternal);
131+
});
132+
133+
// fail with main message
134+
tl.setResult(tl.TaskResult.Failed, toolExecutionError.message);
135+
} else {
136+
tl.setResult(tl.TaskResult.Failed, message);
137+
}
127138
}
128139
else {
129140
tl.setResult(tl.TaskResult.Succeeded, tl.loc("ScriptReturnCode", 0));
@@ -269,6 +280,13 @@ export class azureclitask {
269280
}
270281

271282
private static async getIdToken(connectedService: string) : Promise<string> {
283+
#if NODE20
284+
// since node19 default node's GlobalAgent has timeout 5sec
285+
// keepAlive is set to true to avoid creating default node's GlobalAgent
286+
const webApiOptions = {
287+
keepAlive: true
288+
}
289+
#endif
272290
const jobId = tl.getVariable("System.JobId");
273291
const planId = tl.getVariable("System.PlanId");
274292
const projectId = tl.getVariable("System.TeamProjectId");
@@ -277,7 +295,11 @@ export class azureclitask {
277295
const token = this.getSystemAccessToken();
278296

279297
const authHandler = getHandlerFromToken(token);
298+
#if NODE20
299+
const connection = new WebApi(uri, authHandler, webApiOptions);
300+
#else
280301
const connection = new WebApi(uri, authHandler);
302+
#endif
281303
const api: ITaskApi = await connection.getTaskApi();
282304
const response = await api.createOidcToken({}, projectId, hub, planId, jobId, connectedService);
283305
if (response == null) {

0 commit comments

Comments
 (0)