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

[Dashboard] Fix alias redirect & update error handling #159742

Merged
merged 3 commits into from
Jun 15, 2023

Conversation

ThomThomson
Copy link
Contributor

@ThomThomson ThomThomson commented Jun 14, 2023

Summary

This PR fixes a regression introduced in #150121 & #157437.

Basically what would happen is the following:

  1. The Dashboard renderer would begin loading the dashboard container.
  2. The validation would result in an alias match.
  3. This would update the URL, but also throw an error.
  4. The new fast navigation would see that the url was updated, but it wouldn't redirect because the DashboardContainer was never completed.
  5. The dashboard would infinite load 🔥

This PR fixes that with proper error handling on the dashboard container factory side, and the ability for the dashboard renderer to retry loading the dashboard container if the last load was unsuccessful.

Before

Before.mp4

After

After.mp4

Bonus

Additionally, this PR straightens out the error handling on Dashboard creation. If an error embeddable is returned from the dashboard container factory, the dashboard renderer will render it until the id changes. I got this screenshot by throwing an error in create_dashboard.ts.

Screen Shot 2023-06-14 at 1 53 55 PM

Checklist

Delete any items that are not applicable to this PR.

@ThomThomson ThomThomson added Feature:Dashboard Dashboard related features release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) loe:medium Medium Level of Effort impact:critical This issue should be addressed immediately due to a critical level of impact on the product. labels Jun 14, 2023
@ThomThomson ThomThomson marked this pull request as ready for review June 14, 2023 19:50
@ThomThomson ThomThomson requested a review from a team as a code owner June 14, 2023 19:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)


if (canceled) {
container.destroy();
return;
}

if (isErrorEmbeddable(container)) {
Copy link
Contributor

@nreese nreese Jun 14, 2023

Choose a reason for hiding this comment

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

Shouldn't setLoading(false); get called if container is an error embeddable? The container finished loading, even if it loaded in an error state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, I didn't catch that because the error was rendered if it was present no matter if the loading state was true or not. I've straightened that out!

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

LGTM
code review only

@@ -133,7 +144,9 @@ export const DashboardRenderer = forwardRef<AwaitingDashboardAPI, DashboardRende

return (
<div className={viewportClasses}>
{loading ? loadingSpinner : <div ref={dashboardRoot} />}
{loading && loadingSpinner}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, there should never be a case where loadingSpinner and fatalError.render() are displayed but there could be if both loading and fatalError are set. Would it be clearer to move this logic to a function and use early returns so only a single item is rendered. For example

function renderContent() {
  if (loading) {
    return loadingSpinner;
  }

  if (fatalError) {
    return fatalError.render();
  }

  return (<div ref={dashboardRoot} />);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true. Even if it wouldn't necessarily happen, it's still much cleaner and more understandable to do it this way.

@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
dashboard 358.6KB 358.1KB -514.0B

Page load bundle

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

id before after diff
dashboard 39.4KB 39.9KB +477.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
dashboard 8 7 -1
enterpriseSearch 13 15 +2
securitySolution 410 414 +4
total +5

Total ESLint disabled count

id before after diff
dashboard 8 7 -1
enterpriseSearch 14 16 +2
securitySolution 493 497 +4
total +5

History

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

@ThomThomson ThomThomson merged commit e7528a2 into elastic:main Jun 15, 2023
@ThomThomson ThomThomson added v8.8.2 and removed v8.8.2 labels Jun 15, 2023
@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.8 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 159742

Questions ?

Please refer to the Backport tool documentation

@ThomThomson
Copy link
Contributor Author

Waiting for #157437 to be backported to 8.8 before this one can be.

@renshuki
Copy link
Contributor

renshuki commented Jun 19, 2023

@ThomThomson looks like #157437 got backported to 8.x right?
Could you please backport this as well so it could make it to 8.8.2? Thanks 🙏

ThomThomson added a commit to ThomThomson/kibana that referenced this pull request Jun 19, 2023
Makes dashboard load errors recoverable. Fixes a regression where Alias redirects resulted in infinite loading.

(cherry picked from commit e7528a2)
ThomThomson added a commit that referenced this pull request Jun 19, 2023
#159937)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Dashboard] Fix alias redirect & update error handling
(#159742)](#159742)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Devon
Thomson","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-15T15:57:43Z","message":"[Dashboard]
Fix alias redirect & update error handling (#159742)\n\nMakes dashboard
load errors recoverable. Fixes a regression where Alias redirects
resulted in infinite
loading.","sha":"e7528a2372c846020d565f229da9052ba316284c","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Dashboard","release_note:fix","Team:Presentation","loe:days","impact:critical","backport:prev-minor","v8.9.0"],"number":159742,"url":"https://github.com/elastic/kibana/pull/159742","mergeCommit":{"message":"[Dashboard]
Fix alias redirect & update error handling (#159742)\n\nMakes dashboard
load errors recoverable. Fixes a regression where Alias redirects
resulted in infinite
loading.","sha":"e7528a2372c846020d565f229da9052ba316284c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159742","number":159742,"mergeCommit":{"message":"[Dashboard]
Fix alias redirect & update error handling (#159742)\n\nMakes dashboard
load errors recoverable. Fixes a regression where Alias redirects
resulted in infinite
loading.","sha":"e7528a2372c846020d565f229da9052ba316284c"}}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Dashboard Dashboard related features impact:critical This issue should be addressed immediately due to a critical level of impact on the product. loe:medium Medium Level of Effort release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.8.2 v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants