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

Expose fatalErrors API from the Start contract #55300

Merged
merged 6 commits into from
Jan 21, 2020

Conversation

mshustov
Copy link
Contributor

Summary

This API intended to be used for runtime exceptions. To improve DX, we should provide it as a part of the start contract as well.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

This API is intended to be used for runtime as well.
@mshustov mshustov added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes v7.7.0 labels Jan 20, 2020
@mshustov mshustov requested a review from a team as a code owner January 20, 2020 11:17
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

LGTM, as long as we are exposing this in setup, it makes sense to do the same in start.

On an architectural point of view however, I'm wondering if exposing this API to plugin is really a good thing. Now that Kibana is going to be a 'real' SPA, does that really make sense to be able to halt the whole client-side application 'only' based on a plugin decision/error? Am I the only one that this bother, or should I create an issue to discuss this point?

return fatalErrorsSetup;
public start() {
const { fatalErrors } = this;
if (!fatalErrors) throw new Error('FatalErrorsService#setup() must be invoked before start.');
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT/discussion: Personal opinion, but I always avoided one-liner blocks without brackets. Our linter configuration does not complains so this is not an issue, but do we have conventions on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no lint rule === no convention. I can update anyway to avoid confusion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessary, as I said, linter is alright with this, so no need to change imho

@mshustov
Copy link
Contributor Author

On an architectural point of view however, I'm wondering if exposing this API to plugin is really a good thing. Now that Kibana is going to be a 'real' SPA, does that really make sense to be able to halt the whole client-side application 'only' based on a plugin decision/error? Am I the only one that this bother, or should I create an issue to discuss this point?

It's a substitution for the legacy fatalError API

export function fatalError(error: AngularHttpError | Error | string, location?: string) {

which used mostly to render an error message for the failed operation.
I do agree it can be misused easily. OTOH I can imagine that plugins do need such API in SPA. For example, a data sync operation in the background fails, a plugin might want to prevent any future user interactions to avoid data inconsistency.
Having said that I think it's a legitimate case for a plugin to use this API, but every case should be considered separately.

@mshustov mshustov requested a review from a team as a code owner January 20, 2020 15:39
@pgayvallet
Copy link
Contributor

which used mostly to render an error message for the failed operation.

It does by erasing the whole dom content of the page in current implementation though.

private renderError(injectedMetadata: InjectedMetadataSetup, i18n: I18nStart) {
// delete all content in the rootDomElement
this.rootDomElement.textContent = '';
// create and mount a container for the <FatalErrorScreen>
const container = document.createElement('div');
this.rootDomElement.appendChild(container);
render(
<i18n.Context>
<FatalErrorsScreen
buildNumber={injectedMetadata.getKibanaBuildNumber()}
kibanaVersion={injectedMetadata.getKibanaVersion()}
errorInfo$={this.errorInfo$}
/>
</i18n.Context>,
container
);
}

but that's outside of the scope of the PR.

@mshustov
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

Copy link
Contributor

@streamich streamich left a comment

Choose a reason for hiding this comment

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

AppArch changes LGTM.

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

LGTM

@mshustov mshustov merged commit 4971a2c into elastic:master Jan 21, 2020
@mshustov mshustov deleted the expose-fatal-errors-start branch January 21, 2020 11:59
mshustov added a commit to mshustov/kibana that referenced this pull request Jan 21, 2020
* Expose FatalErrors from the Start contract.

This API is intended to be used for runtime as well.

* update docs

* update data plugin snapshot to fix tests

* address comments

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 21, 2020
* master:
  [State Management] remove AppState from Dashboard app (elastic#54105)
  Expose fatalErrors API from the Start contract (elastic#55300)
  [BUG] Data fetching twice on discover timefilter change  (elastic#55279)
  [Mappings editor] Add missing max_shingle_size parameter to search_as_you_type (elastic#55161)
  [Logs UI] Fix z-index of logs page toolbar (elastic#54469)
  removes CTA from Task Manager info message (elastic#55334)
mshustov added a commit that referenced this pull request Jan 21, 2020
* Expose FatalErrors from the Start contract.

This API is intended to be used for runtime as well.

* update docs

* update data plugin snapshot to fix tests

* address comments

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@mshustov
Copy link
Contributor Author

@pgayvallet #55402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants