Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover] Replace RxJS firstValueFrom with RxJS lastValueFrom to prevent problem with partial results #134682

Merged
merged 7 commits into from
Jun 20, 2022

Conversation

kertal
Copy link
Member

@kertal kertal commented Jun 17, 2022

Summary

The recent upgrade of RxJS #129087 led to refactoring of code. Some .toPromise() was replaced with firstValueFrom. This worked unless a partial result was returned before the final result. This PR replaces firstValueFrom with lastValueFrom, to make sure, the final result is returned.

Fixes #134138

Checklist

@kertal kertal added Feature:Discover Discover Application Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. labels Jun 17, 2022
@kertal kertal self-assigned this Jun 17, 2022
* helper function to build a query body for Elasticsearch
* https://www.elastic.co/guide/en/elasticsearch/reference/current//query-dsl-ids-query.html
*/
export function buildSearchBody(
Copy link
Member Author

@kertal kertal Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a little code style change, moving the helper function to the bottom, so when scrolling the doc, the important function is displayed first

@kertal kertal added release_note:skip Skip the PR/issue when compiling release notes v8.4.0 v8.3.0 auto-backport Deprecated - use backport:version if exact versions are needed labels Jun 20, 2022
Comment on lines +214 to +231
mockSearchResult.next({
isPartial: true,
isRunning: false,
rawResponse: {
hits: {
hits: [],
},
},
});
mockSearchResult.next({
isPartial: false,
isRunning: false,
rawResponse: {
hits: {
hits: [record],
},
},
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dear @Dosant , if you have minute, could you have a look at the unit tests, they work, but I would love to know, if I could make them better ❤️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that will do it 👍 should capture the flow well.

Theoretically it is possible to make them behave more real-world by adding delay+fake timers between emits. Maybe even use rxjs-marbles for it.
But I think that's already good enough for the current use case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx @Dosant , for confirming 👍

@kertal kertal marked this pull request as ready for review June 20, 2022 13:48
@kertal kertal requested a review from a team as a code owner June 20, 2022 13:48
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@kertal kertal changed the title [Discover] Replace firstValueFrom with lastValueFrom [Discover] Replace RxJS firstValueFrom with RxJS lastValueFrom to prevent problem with partial results Jun 20, 2022
Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 488.1KB 488.1KB -8.0B
stackAlerts 204.0KB 204.0KB -2.0B
total -10.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @kertal

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.3

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jun 22, 2022
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jun 22, 2022
kibanamachine added a commit that referenced this pull request Jun 22, 2022
…to prevent problem with partial results (#134682) (#134761)

* [Discover] Replace RxJS firstValueFrom with RxJS lastValueFrom to prevent problem with partial results (#134682)

(cherry picked from commit 69cd603)

* Update es_query_expression.test.tsx

Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Discover Discover Application release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.3.0 v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Endpoint alert JSON view erroring in discovery
6 participants