diff --git a/x-pack/plugins/watcher/server/plugin.ts b/x-pack/plugins/watcher/server/plugin.ts index 88cecf533522..dcbc7e652687 100644 --- a/x-pack/plugins/watcher/server/plugin.ts +++ b/x-pack/plugins/watcher/server/plugin.ts @@ -10,6 +10,7 @@ declare module 'kibana/server' { } } +import { once } from 'lodash'; import { CoreSetup, IScopedClusterClient, @@ -52,11 +53,11 @@ export class WatcherServerPlugin implements Plugin { getLicenseStatus: () => this.licenseStatus, }; - const getWatcherEsClient = async () => { + const getWatcherEsClient = once(async () => { const [coreStart] = await getStartServices(); const config = { plugins: [elasticsearchJsPlugin] }; return coreStart.elasticsearch.legacy.createClient('watcher', config); - }; + }); http.registerRouteHandlerContext('watcher', (ctx, request) => { return { client: {