-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Migrate most plugins to synchronous lifecycle #89562
Migrate most plugins to synchronous lifecycle #89562
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation review
if (isPromise(startContract)) { | ||
return startContract.then((resolvedContract) => { | ||
this.startDependencies$.next([startContext, plugins, resolvedContract]); | ||
return resolvedContract; | ||
}); | ||
} else { | ||
this.startDependencies$.next([startContext, plugins, startContract]); | ||
return startContract; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to dissociate promises from other return values in the plugin system, so the plugin wrapper can no longer be async. This is why I need to chain the promise to resolve the startDependencies
if (this.coreContext.env.mode.dev) { | ||
// eslint-disable-next-line no-console | ||
console.log( | ||
`Plugin ${pluginName} is using asynchronous setup lifecycle. Asynchronous plugins support will be removed in a later version.` | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until we implement a client-side logger, we don't have any other options than just console.log
the warning for client-side plugins
private instance?: | ||
| Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart> | ||
| AsyncPlugin<TSetup, TStart, TPluginsSetup, TPluginsStart>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started by adding a EitherPlugin = Plugin | AsyncPlugin
type, but as this is only a temporary measure, I think that having the explicit composite type in the few places we are using plugins is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES UI changed LGTM. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work for the infra
plugin, thank you 👍
Out of curiosity, do you remember if the config
semantics changes since the new platform was introduced? We used the async access to config
because the config wasn't loaded early enough. A simple test shows it is now. 🤷
The synchronous config access API was added last week by #88981, but apart from that I don't think we changed the behavior of the |
@elastic/endpoint-app-team @elastic/kibana-presentation @elastic/stack-monitoring-ui still waiting for your reviews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for Stack Monitoring!
…-async-config-plugins
💚 Build SucceededMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
* first pass * migrate more plugins * migrate yet more plugins * more oss plugins * fix test file * change Plugin signature on the client-side too * fix test types * migrate OSS client-side plugins * migrate OSS client-side test plugins * migrate xpack client-side plugins * revert fix attempt on fleet plugin * fix presentation start signature * fix yet another signature * add warnings for server-side async plugins in dev mode * remove unused import * fix isPromise * Add client-side deprecations * update migration examples * update generated doc * fix xpack unit tests * nit * (will be reverted) explicitly await for license to be ready in the auth hook * Revert "(will be reverted) explicitly await for license to be ready in the auth hook" This reverts commit fdf73fe * restore await on on promise contracts * Revert "(will be reverted) explicitly await for license to be ready in the auth hook" This reverts commit fdf73fe * Revert "restore await on on promise contracts" This reverts commit c5f2fe5 * add delay before starting tests in FTR * update deprecation ts doc * add explicit contract for monitoring setup * migrate monitoring plugin to sync * change plugin timeout to 10sec * use delay instead of silence # Conflicts: # x-pack/plugins/xpack_legacy/server/plugin.ts
* Migrate most plugins to synchronous lifecycle (#89562) * first pass * migrate more plugins * migrate yet more plugins * more oss plugins * fix test file * change Plugin signature on the client-side too * fix test types * migrate OSS client-side plugins * migrate OSS client-side test plugins * migrate xpack client-side plugins * revert fix attempt on fleet plugin * fix presentation start signature * fix yet another signature * add warnings for server-side async plugins in dev mode * remove unused import * fix isPromise * Add client-side deprecations * update migration examples * update generated doc * fix xpack unit tests * nit * (will be reverted) explicitly await for license to be ready in the auth hook * Revert "(will be reverted) explicitly await for license to be ready in the auth hook" This reverts commit fdf73fe * restore await on on promise contracts * Revert "(will be reverted) explicitly await for license to be ready in the auth hook" This reverts commit fdf73fe * Revert "restore await on on promise contracts" This reverts commit c5f2fe5 * add delay before starting tests in FTR * update deprecation ts doc * add explicit contract for monitoring setup * migrate monitoring plugin to sync * change plugin timeout to 10sec * use delay instead of silence # Conflicts: # x-pack/plugins/xpack_legacy/server/plugin.ts * fix mock
* master: (55 commits) [APM-UI][E2E] use githubNotify step (elastic#90514) [APM] Export ProcessorEvent type (elastic#90540) [Lens] Retain column config (elastic#90048) [Data Table] Add unit tests (elastic#90173) Migrate most plugins to synchronous lifecycle (elastic#89562) skip flaky suite (elastic#90555) skip flaky suite (elastic#64473) [actions] improve email action doc (elastic#90020) [Fleet] Support Fleet server system indices (elastic#89372) skip flaky suite (elastic#90552) Bump immer dependencies (elastic#90267) Unrevert "Migrations v2: don't auto-create indices + FTR/esArchiver support (elastic#85778)" (elastic#89992) [Search Sessions] Use sync config (elastic#90138) chore(NA): add safe guard to remove bazelisk from yarn global at bootstrap (elastic#90538) [test] Await retry.waitFor (elastic#90456) chore(NA): integrate build buddy with our bazel setup and remote cache for ci (elastic#90116) Skip failing suite (elastic#90526) [Fleet] Fix incorrect conversion of string to numeric values in agent YAML (elastic#90371) [Docs] Update reporting troubleshooting for arm rhel/centos (elastic#90385) chore(NA): build bazel projects all at once in the distributable build process (elastic#90328) ...
Summary
Part of #53268, was unblocked by #88981
Fix #71925
Fix #74395
This PR migrates most of the existing asynchronous plugins to synchronous lifecycle.
Plugin
signature to no longer accept returning promises fromsetup
andstart
AsyncPlugin
interface (same interface as the oldPlugin
)AsyncPlugin
instead ofPlugin
for plugins I couldn't migratePlugin
interface on some plugins + some overall cleanupRemaining async plugins
There are only
32 plugins this PR does not migrate:monitoringaddressed by [Monitoring] Fixed alert imports #89935I will create a distinct issue to discuss about those with the owners once this PR is merged.
Checklist