Plugin doesn't work after Kibana update

Hi,

We want to upgrade our stack from 5.2 to 6.2.4. As suggested in the documentation, first I'm trying to upgrade the stack to 5.6.9 so I'll be able to do a rolling update to 6.2.4 from that.

However we have a custom made Kibana plugin, and it doesn't seem to work in 5.6.9. When I want to start it, I get the following error:

Fatal Error
Uncaught TypeError: Cannot read property 'get' of undefined (https://kibana-host/bundles/custom_plugin.bundle.js?v=15629:2)
Version: 5.6.9
Build: 15629
Error: Uncaught TypeError: Cannot read property 'get' of undefined (https://kibana-host/bundles/custom_plugin.bundle.js?v=15629:2)
at window.onerror (https://kibana-host/bundles/custom_plugin.bundle.js?v=15629:90:23848)

The console says:

Error: Uncaught TypeError: Cannot read property 'get' of undefined (https://kibana-host/bundles/custom_plugin.bundle.js?v=15629:2)
at window.onerror (commons.bundle.js?v=15629:90)
Notifier._showFatal @ commons.bundle.js?v=15629:89
Notifier.fatal @ commons.bundle.js?v=15629:89
wrapper @ commons.bundle.js?v=15629:1
window.onerror @ commons.bundle.js?v=15629:90
error (async)
2510 @ commons.bundle.js?v=15629:90
webpack_require @ commons.bundle.js?v=15629:1
2446 @ commons.bundle.js?v=15629:87
webpack_require @ commons.bundle.js?v=15629:1
0 @ custom_plugin.bundle.js?v=15629:1
webpack_require @ commons.bundle.js?v=15629:1
window.webpackJsonp @ commons.bundle.js?v=15629:1
(anonymous) @ custom_plugin.bundle.js?v=15629:1
Uncaught TypeError: Cannot read property 'get' of undefined
at new DirectiveManager (custom_plugin.bundle.js?v=15629:2)
at Object.4569 (custom_plugin.bundle.js?v=15629:2)
at webpack_require (commons.bundle.js?v=15629:1)
at Object.4567 (custom_plugin.bundle.js?v=15629:2)
at webpack_require (commons.bundle.js?v=15629:1)
at Object.4561 (custom_plugin.bundle.js?v=15629:1)
at webpack_require (commons.bundle.js?v=15629:1)
at Object.0 (custom_plugin.bundle.js?v=15629:1)
at webpack_require (commons.bundle.js?v=15629:1)
at window.webpackJsonp (commons.bundle.js?v=15629:1)
DirectiveManager @ custom_plugin.bundle.js?v=15629:2
4569 @ custom_plugin.bundle.js?v=15629:2
webpack_require @ commons.bundle.js?v=15629:1
4567 @ custom_plugin.bundle.js?v=15629:2
webpack_require @ commons.bundle.js?v=15629:1
4561 @ custom_plugin.bundle.js?v=15629:1
webpack_require @ commons.bundle.js?v=15629:1
0 @ custom_plugin.bundle.js?v=15629:1
webpack_require @ commons.bundle.js?v=15629:1
window.webpackJsonp @ commons.bundle.js?v=15629:1
(anonymous) @ custom_plugin.bundle.js?v=15629:1
Uncaught Error: Uncaught TypeError: Cannot read property 'get' of undefined (https://kibana-host/bundles/custom_plugin.bundle.js?v=15629:2)
at window.onerror (commons.bundle.js?v=15629:90)

Was there a change in Angular or Node JS I'm not aware of which makes the code not compatible with the newer version of Kibana?

I think I managed to find the problem.

At one point in the plugin's code there's this line:

import * as uiModules from 'ui/modules';

However it becomes undefined. As I understand, this is a directory which should be available to any plugin which invokes it: https://www.elastic.co/guide/en/kibana/current/development-dependencies.html

What could be the cause of this? The exact same code runs without any issue in 5.2.0.

In the end this thread helped me to solve my problem:

I had to replace

import * as uiModules from 'ui/modules';

this.module = uiModules.default.get('app/custom_plugin', );

with this

import { uiModules } from 'ui/modules';

this.module = uiModules.get('app/custom_plugin', );

I had to realize that importing "ui/routes" has also changed.

From this

import * as uiRoutes from 'ui/routes';

this.route = uiRoutes.default;

to this

import uiRoutes from 'ui/routes';

this.route = uiRoutes;

Hi there, thanks for posting your solution. Nice work figuring it out!

Best,
CJ

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.