Skip to content

Change Plugin.stop signature to allow asynchronous stop lifecycle #83612

@pgayvallet

Description

@pgayvallet

Initial discussion started because of #80941. In this issue, the event_log plugin needs to perform some asynchronous cleanup when Kibana stops.

Our current Plugin interface does not declare stop as possibly asynchronous:

export interface Plugin<
TSetup = void,
TStart = void,
TPluginsSetup extends object = object,
TPluginsStart extends object = object
> {
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
stop?(): void;
}

Even if technically, we are awaiting for plugins to stop:

while (this.satupPlugins.length > 0) {
const pluginName = this.satupPlugins.pop()!;
this.log.debug(`Stopping plugin "${pluginName}"...`);
await this.plugins.get(pluginName)!.stop();
}

I also know that we got plans to deprecates asycnhronous setup and start methods. However, even when we'll do that, I have the feeling that allowing asynchronous stop lifecycle would make sense, as if stop is only synchronous, there is effectively no way to perform async cleanups during this stage (this process will just terminate if the method needs to perform an async call)

So my two questions:

  • Should we 'fix' our Plugin.stop signature to reflect that we currently allow plugins to return promises and that we do wait for them?
  • Do we want to keep this behavior, and if so, do we want to preserve it even when we'll move to sync-only setup and start?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Team:CorePlatform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//discussenhancementNew value added to drive a business result

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions