From 9aa9d4e86a0b82ec02ce762849c8fe4afe819207 Mon Sep 17 00:00:00 2001 From: Denis Nikulin Date: Tue, 10 Dec 2024 12:53:50 +0400 Subject: [PATCH] Fix process invocation for PowerShell handler (#1080) * Replaced the method of process awaiting --- powershell/VstsTaskSdk/ToolFunctions.ps1 | 8 ++------ powershell/package-lock.json | 8 ++++---- powershell/package.json | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/powershell/VstsTaskSdk/ToolFunctions.ps1 b/powershell/VstsTaskSdk/ToolFunctions.ps1 index bb6f8d6fc..35e621887 100644 --- a/powershell/VstsTaskSdk/ToolFunctions.ps1 +++ b/powershell/VstsTaskSdk/ToolFunctions.ps1 @@ -202,13 +202,9 @@ function Invoke-Process { $processOptions.Add("RedirectStandardError", $StdErrPath) } - # TODO: For some reason, -Wait is not working on agent. - # Agent starts executing the System usage metrics and hangs the step forever. + # We can't use -Wait in this case as it waits for the whole process tree, it can lead to unexprected hangs $proc = Start-Process @processOptions - - # https://stackoverflow.com/a/23797762 - $null = $($proc.Handle) - $proc.WaitForExit() + Wait-Process -InputObject $proc $procExitCode = $proc.ExitCode Write-Verbose "Exit code: $procExitCode" diff --git a/powershell/package-lock.json b/powershell/package-lock.json index 863619859..2445cf4fa 100644 --- a/powershell/package-lock.json +++ b/powershell/package-lock.json @@ -1,6 +1,6 @@ { "name": "vsts-task-sdk", - "version": "0.21.1", + "version": "0.21.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -408,9 +408,9 @@ } }, "typescript": { - "version": "4.9.5", - "resolved": "https://pkgs.dev.azure.com/mseng/PipelineTools/_packaging/PipelineTools_PublicPackages/npm/registry/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha1-CVl5+bzA0J2jJNWNA86Pg3TL5lo=", + "version": "4.0.2", + "resolved": "https://pkgs.dev.azure.com/mseng/PipelineTools/_packaging/PipelineTools_PublicPackages/npm/registry/typescript/-/typescript-4.0.2.tgz", + "integrity": "sha1-fqfIh3fHI8aB4zv3mIvl0AjQWsI=", "dev": true }, "utf8-byte-length": { diff --git a/powershell/package.json b/powershell/package.json index 3684d0b52..dadeca674 100644 --- a/powershell/package.json +++ b/powershell/package.json @@ -1,6 +1,6 @@ { "name": "vsts-task-sdk", - "version": "0.21.1", + "version": "0.21.2", "private": true, "scripts": { "build": "node make.js build", @@ -16,6 +16,6 @@ "mocha": "5.2.0", "nodejs-file-downloader": "^4.11.1", "shelljs": "^0.8.5", - "typescript": "^4.0.2" + "typescript": "4.0.2" } }