Skip to content

Commit

Permalink
Temporarily prevents task-kill exceptions on Windows when it is pas…
Browse files Browse the repository at this point in the history
…sed a `pid` for a process that is already dead (#2842) (#2844)

Ref: #2811

Signed-off-by: Miki <[email protected]>

Signed-off-by: Miki <[email protected]>
(cherry picked from commit 4fd67de)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 3dd838b commit 5926313
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/osd-opensearch/src/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,22 @@ exports.Cluster = class Cluster {
throw new Error('OpenSearch has not been started');
}

await treeKillAsync(this._process.pid);
/* Temporary fix for https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2811
*
* `tree-kill` behaves differently on Windows, where it throws if `pid` is already dead, when
* compared to other operating systems, where it silently returns.
*/
try {
await treeKillAsync(this._process.pid);
} catch (ex) {
console.log('ex.message', ex.message);
if (
process.platform === 'win32' &&
!ex.message?.includes(`The process "${this._process.pid}" not found`)
) {
throw ex;
}
}

await this._outcome;
}
Expand Down

0 comments on commit 5926313

Please sign in to comment.