Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

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 (opensearch-project#2842)

Ref: opensearch-project#2811

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

Signed-off-by: Miki <[email protected]>
Signed-off-by: David Sinclair <[email protected]>
  • Loading branch information
AMoo-Miki authored and sikhote committed Apr 24, 2023
1 parent f441e1d commit ddf200f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Change geckodriver version to make consistency ([#2772](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2772))
- [Multi DataSource] Update default audit log path ([#2793](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2793))
- [Table Visualization] Fix first column sort issue ([#2828](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2828))
- Temporary workaround for task-kill exceptions on Windows when it is passed a pid for a process that is already dead ([#2842](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2842))

### 🚞 Infrastructure

Expand Down
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 ddf200f

Please sign in to comment.