Skip to content

[data.search] Fix unhandled promise rejections#181785

Merged
lukasolson merged 3 commits intoelastic:mainfrom
lukasolson:fix/168957
May 1, 2024
Merged

[data.search] Fix unhandled promise rejections#181785
lukasolson merged 3 commits intoelastic:mainfrom
lukasolson:fix/168957

Conversation

@lukasolson
Copy link
Copy Markdown
Contributor

Summary

Resolves #168957.

It turns out the underlying issue was resolved in #170041 (unhandled errors when deleting not being handled). However this still left it up to consumers of pollSearch to be 100% sure they weren't leaking unhandled promise rejections. This adds code directly to pollSearch that will handle rejections if they aren't handled in the calling code. It also adds tests to consumers of pollSearch to make sure they don't barf in the case that the cancel function errors.

Checklist

@lukasolson lukasolson self-assigned this Apr 25, 2024
@lukasolson
Copy link
Copy Markdown
Contributor Author

/ci

@lukasolson lukasolson marked this pull request as ready for review April 26, 2024 17:42
@lukasolson lukasolson requested review from a team as code owners April 26, 2024 17:42
@lukasolson lukasolson added Feature:Search Querying infrastructure in Kibana Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// labels Apr 26, 2024
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@lukasolson lukasolson added the release_note:skip Skip the PR/issue when compiling release notes label Apr 26, 2024
Copy link
Copy Markdown
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Code review only 👍

@kibana-ci
Copy link
Copy Markdown

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #38 / maps app maps loaded from sample data "before all" hook in "maps loaded from sample data"

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 417.5KB 417.6KB +98.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
data 52 54 +2

Total ESLint disabled count

id before after diff
data 54 56 +2

History

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

cc @lukasolson

Copy link
Copy Markdown
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Thanks for addressing it! LGTM 👍


const safeCancel = () =>
cancel?.().catch((e) => {
console.error(e); // eslint-disable-line no-console
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we should use the Core Logger for this instead? Or can we not because it's in common?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, since it's used on both the client and server this presents some challenges. I tried passing in the Logger client-side and I'm not sure where it actually logs to because I don't see it in the console. It's also just a bit convoluted since we have to pass the logger all the way from the plugin down to pollSearch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense, thanks for looking into it anyway!

@lukasolson lukasolson merged commit e4a381a into elastic:main May 1, 2024
@kibanamachine kibanamachine added v8.15.0 backport:skip This PR does not require backporting labels May 1, 2024
TinLe added a commit to TinLe/kibana that referenced this pull request May 1, 2024
* master: (1654 commits)
  Bump ejs from 3.1.9 to 3.1.10
  Don't render exceptions flyout if data is loading (elastic#181588)
  Enable value list modal (elastic#181593)
  skip flaky suite (elastic#181777)
  skip failing test suite (elastic#182263)
  [Mappings Editor] Disable _source field in serverless (elastic#181712)
  [data.search] Fix unhandled promise rejections (elastic#181785)
  [Fleet] Fix logic for detecting first time Elastic Agent users (elastic#182214)
  [ML] Decouple data_visualizer from MapEmbeddable (elastic#181928)
  [ES|QL] Sorting accepts expressions (elastic#181916)
  [ML] Single Metric Viewer: ensures chart displays correctly when opening from a job annotation (elastic#182176)
  Adding optional Description field to Roles APIs (elastic#182039)
  Upgrade Markdown-it to 14.1.0 (elastic#182244)
  Bump xml-crypto from 5.0.0 to 6.0.0
  [DOCS] Fix docs and screenshots for rule creation changes (elastic#181925)
  Update dependency elastic-apm-node to ^4.5.3 (main) (elastic#182236)
  [Obs AI Assistant] register alert details context in observability plugin (elastic#181501)
  Add `@typescript-eslint/no-floating-promises` (elastic#181456)
  [Playground] Propagate Error message into FE (elastic#182201)
  [ES|QL] Rename the setting to a more generic one and move to the general section (elastic#182074)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Search Querying infrastructure in Kibana release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v8.15.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhandled Promise rejection when cancelling an async search

6 participants