Skip to content

Commit

Permalink
[8.18] [scout] Don't mix await with promise callbacks (#211905) (#2…
Browse files Browse the repository at this point in the history
…11914)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[scout] Don't mix `await` with promise callbacks
(#211905)](#211905)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"David
Olaru","email":"dolaru@elastic.co"},"sourceCommit":{"committedDate":"2025-02-20T15:05:17Z","message":"[scout]
Don't mix `await` with promise callbacks (#211905)\n\n##
Summary\n\nThere's a high likelihood that this causes some unwanted
behavior where\nthe promise is not resolved and the `node` process just
exists without\nany
error.","sha":"1147bb65dd655d9dac42f866c61eb23af42d2d74","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[scout]
Don't mix `await` with promise
callbacks","number":211905,"url":"https://github.com/elastic/kibana/pull/211905","mergeCommit":{"message":"[scout]
Don't mix `await` with promise callbacks (#211905)\n\n##
Summary\n\nThere's a high likelihood that this causes some unwanted
behavior where\nthe promise is not resolved and the `node` process just
exists without\nany
error.","sha":"1147bb65dd655d9dac42f866c61eb23af42d2d74"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/211905","number":211905,"mergeCommit":{"message":"[scout]
Don't mix `await` with promise callbacks (#211905)\n\n##
Summary\n\nThere's a high likelihood that this causes some unwanted
behavior where\nthe promise is not resolved and the `node` process just
exists without\nany
error.","sha":"1147bb65dd655d9dac42f866c61eb23af42d2d74"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: David Olaru <dolaru@elastic.co>
  • Loading branch information
kibanamachine and dolaru authored Feb 20, 2025
1 parent 729029d commit bdeda8a
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/kbn-scout-reporting/src/helpers/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ export async function getValidatedESClient(
const { log, cli = false } = helperSettings;
const es = new ESClient(esClientOptions);

await es.info().then(
(esInfo) => {
if (log !== undefined) {
log.info(`Connected to Elasticsearch node '${esInfo.name}'`);
}
},
(err) => {
const msg = `Failed to connect to Elasticsearch\n${err}`;
throw cli ? createFailError(msg) : Error(msg);
try {
const esInfo = await es.info();
if (log !== undefined) {
log.info(`Connected to Elasticsearch node '${esInfo.name}'`);
}
);
} catch (err) {
const msg = `Failed to connect to Elasticsearch\n${err}`;
throw cli ? createFailError(msg) : Error(msg);
}

return es;
}

0 comments on commit bdeda8a

Please sign in to comment.