-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Description
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:
kibana/src/core/server/plugins/types.ts
Lines 251 to 260 in f8d796a
| 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:
kibana/src/core/server/plugins/plugins_system.ts
Lines 169 to 174 in f49ee06
| 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.stopsignature 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
setupandstart?