Gnome-shell-system-monitor-applet: TypeError: this._construct is undefined

Created on 9 Mar 2019  ยท  11Comments  ยท  Source: paradoxxxzero/gnome-shell-system-monitor-applet

Causes the extension to not work. Seen on Ubuntu Disco Dingo. Doesn't make a difference if it is installed via the repo or the website.

In case it is relevant, the following was seen in journalctl just before the error.

Some code accessed the property 'ENABLED_EXTENSIONS_KEY' on the module 'extensionSystem'. That property was defined with 'let' or 'const' inside the module. This was previously supported, but is not correct according to the ES6 standard. Any symbols to be exported from a module must be defined with 'var'. The property access will work as previously for the time being, but please fix your code anyway.

This extension is pretty awesome. Longtime iStats user here.

Most helpful comment

Hello guys,

the patch did the trick for me, feel free to integrate into codebase.

Cheers

--- extension.js    2019-03-29 09:17:41.000000000 +1000
+++ /usr/share/gnome-shell/extensions/[email protected]/extension.js  2019-03-29 12:42:46.836506249 +1000
@@ -255,12 +255,10 @@
     },
 });

-const smDialog = Lang.Class({
-    Name: 'SystemMonitor.smDialog',
-    Extends: ModalDialog.ModalDialog,
+class smDialog extends ModalDialog.ModalDialog {

-    _init: function () {
-        this.parent({styleClass: 'prompt-dialog'});
+    constructor() {
+        super({styleClass: 'prompt-dialog'});
         let mainContentBox = new St.BoxLayout({style_class: 'prompt-dialog-main-layout',
             vertical: false});
         this.contentLayout.add(mainContentBox,
@@ -296,9 +294,9 @@
                 key: Clutter.Escape
             }
         ]);
-    },
+    }

-});
+}

 const Chart = new Lang.Class({
     Name: 'SystemMonitor.Chart',
@@ -642,45 +640,39 @@
     }
 });

-const TipItem = new Lang.Class({
-    Name: 'SystemMonitor.TipItem',
-    Extends: PopupMenu.PopupBaseMenuItem,
-
-    _init: function () {
-        PopupMenu.PopupBaseMenuItem.prototype._init.call(this);
+class TipItem extends PopupMenu.PopupBaseMenuItem {
+    constructor() {
+        super();
         this.actor.remove_style_class_name('popup-menu-item');
         this.actor.add_style_class_name('sm-tooltip-item');
     }
-});
+}
+
+class TipMenu extends PopupMenu.PopupMenuBase {

-const TipMenu = new Lang.Class({
-    Name: 'SystemMonitor.TipMenu',
-    Extends: PopupMenu.PopupMenuBase,
-
-    _init: function (sourceActor) {
-        // PopupMenu.PopupMenuBase.prototype._init.call(this, sourceActor, 'sm-tooltip-box');
-        this.parent(sourceActor, 'sm-tooltip-box');
-        this.actor = new Shell.GenericContainer();
-        this.actor.connect('get-preferred-width',
+    constructor (sourceActor) {
+        super(sourceActor, 'sm-tooltip-box');
+        this.actor = new St.Widget();
+        this.connect('get-preferred-width',
             Lang.bind(this, this._boxGetPreferredWidth));
-        this.actor.connect('get-preferred-height',
+        this.connect('get-preferred-height',
             Lang.bind(this, this._boxGetPreferredHeight));
-        this.actor.connect('allocate', Lang.bind(this, this._boxAllocate));
+        this.connect('allocate', Lang.bind(this, this._boxAllocate));
         this.actor.add_actor(this.box);
-    },
-    _boxGetPreferredWidth: function (actor, forHeight, alloc) {
+    }
+    _boxGetPreferredWidth (actor, forHeight, alloc) {
         // let columnWidths = this.getColumnWidths();
         // this.setColumnWidths(columnWidths);

         [alloc.min_size, alloc.natural_size] = this.box.get_preferred_width(forHeight);
-    },
-    _boxGetPreferredHeight: function (actor, forWidth, alloc) {
+    }
+    _boxGetPreferredHeight (actor, forWidth, alloc) {
         [alloc.min_size, alloc.natural_size] = this.box.get_preferred_height(forWidth);
-    },
-    _boxAllocate: function (actor, box, flags) {
+    }
+    _boxAllocate (actor, box, flags) {
         this.box.allocate(box, flags);
-    },
-    _shift: function () {
+    }
+    _shift() {
         // Probably old but works
         let node = this.sourceActor.get_theme_node();
         let contentbox = node.get_content_box(this.sourceActor.get_allocation_box());
@@ -702,8 +694,8 @@
             tipy = allocation.y1 - height; // If it is at the bottom, place the tooltip above instead of below
         }
         this.actor.set_position(tipx, tipy);
-    },
-    open: function (animate) {
+    }
+    open(animate) {
         if (this.isOpen) {
             return;
         }
@@ -713,13 +705,13 @@
         this._shift();
         this.actor.raise_top();
         this.emit('open-state-changed', true);
-    },
-    close: function (animate) {
+    }
+    close (animate) {
         this.isOpen = false;
         this.actor.hide();
         this.emit('open-state-changed', false);
     }
-});
+}

 const TipBox = new Lang.Class({
     Name: 'SystemMonitor.TipBox',

All 11 comments

This might be how it was fixed in dash to dock: https://github.com/micheleg/dash-to-dock/pull/881/commits/6382e38b195781f0bf89a8d9b0edc8d4fa387e45 so it may apply here also.

Ubuntu 19.04 GS 3.32

Extension "[email protected]" had error: TypeError: this._construct is undefined
0 check_sensors() ["/usr/share/gnome-shell/extensions/[email protected]/prefs.js":60]
1 add() ["/usr/share/gnome-shell/extensions/[email protected]/prefs.js":227]
3 _init/<() ["/usr/share/gnome-shell/extensions/[email protected]/prefs.js":362]
6 _init() ["/usr/share/gnome-shell/extensions/[email protected]/prefs.js":318]
10 buildPrefsWidget() ["/usr/share/gnome-shell/extensions/[email protected]/prefs.js":377]

Ubuntu 19.04 here, same issue. This may be actually be gnome-shell issue or missing gir1.2 stuff?

 3ๆœˆ 11 18:48:12 A285 gnome-shell[2279]: JS WARNING: [resource:///org/gnome/gjs/modules/_legacy.js 67]: reference to undefined property "_construct"
 3ๆœˆ 11 18:48:12 A285 gnome-shell[2279]: Extension "[email protected]" had error: TypeError: this._construct is undefined

What / where is this _construct thing anyway?

Did some research, this issue is totally related to gnome-shell JS shift to ES6, where many legacy stuff is not only deprecated but also not allowed anymore... Some non-trivial re-factor may be necessary, along these lines:

Now, I've tried doing this myself, in-progress PR following, but I still haven't made it work, the changes I could write based on a short notice (based upon dash-to-dock implementation) make gnome-shell crash on me :|

The above code push is the fix attempt (which also contains ugly hack for #486). The changes works around TypeError: this._construct is undefined, however it crashes my gnome-shell hard:

 3ๆœˆ 14 19:15:52 A285 org.gnome.Shell.desktop[30874]: current session already has an ibus-daemon.
 3ๆœˆ 14 19:15:53 A285 gnome-shell[30874]: g_dir_open_with_errno: assertion 'path != NULL' failed
 3ๆœˆ 14 19:15:53 A285 gnome-shell[30874]: g_filename_to_utf8: assertion 'opsysstring != NULL' failed
 3ๆœˆ 14 19:15:53 A285 gnome-shell[30874]: g_dir_open_with_errno: assertion 'path != NULL' failed
 3ๆœˆ 14 19:15:53 A285 gnome-shell[30874]: g_filename_to_utf8: assertion 'opsysstring != NULL' failed
 3ๆœˆ 14 19:15:53 A285 gnome-shell[30874]: Telepathy is not available, chat integration will be disabled.
 3ๆœˆ 14 19:15:53 A285 gnome-shell[30874]: [System monitor] applet init from /home/samir/.local/share/gnome-shell/extensions/[email protected]
 3ๆœˆ 14 19:15:53 A285 gnome-shell[30874]: [System monitor] applet enabling
 3ๆœˆ 14 19:15:53 A285 gnome-shell[30874]: Settings schema 'org.gnome.shell.extensions.system-monitor' does not contain a key named '-graph-width'
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: GNOME Shell crashed with signal 5
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: == Stack trace for context 0x559922e68270 ==
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #0   5599232ece70 i   /home/samir/.local/share/gnome-shell/extensions/[email protected]/extension.js:830 (7eff7c06e700 @ 506)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #1   5599232ecdd0 i   /home/samir/.local/share/gnome-shell/extensions/[email protected]/extension.js:1175 (7eff7c06f550 @ 9)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #2   5599232ecd18 i   /home/samir/.local/share/gnome-shell/extensions/[email protected]/extension.js:1369 (7eff7c06f8b0 @ 283)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #3   5599232ecc18 i   /home/samir/.local/share/gnome-shell/extensions/[email protected]/extension.js:2323 (7eff7c072af0 @ 628)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #4   5599232ecb68 i   resource:///org/gnome/shell/ui/extensionSystem.js:131 (7effc4c4a670 @ 504)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #5   5599232ecad0 i   resource:///org/gnome/shell/ui/extensionSystem.js:177 (7effc4c4a790 @ 241)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #6   5599232eca50 i   resource:///org/gnome/shell/ui/extensionSystem.js:324 (7effc4c4aee0 @ 13)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #7   7ffd862cf890 b   resource:///org/gnome/gjs/modules/signals.js:128 (7effc4ecb820 @ 386)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #8   5599232ec970 i   resource:///org/gnome/shell/misc/extensionUtils.js:251 (7effc4c50790 @ 454)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #9   5599232ec8e0 i   resource:///org/gnome/shell/misc/extensionUtils.js:257 (7effc4c508b0 @ 28)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #10   7ffd862d10c0 b   resource:///org/gnome/shell/misc/fileUtils.js:25 (7effc4c0b430 @ 318)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #11   5599232ec850 i   resource:///org/gnome/shell/misc/extensionUtils.js:256 (7effc4c50820 @ 72)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #12   5599232ec7c0 i   resource:///org/gnome/shell/ui/extensionSystem.js:326 (7effc4c4ae50 @ 201)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #13   5599232ec740 i   resource:///org/gnome/shell/ui/extensionSystem.js:334 (7effc4c4af70 @ 36)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #14   5599232ec6c0 i   resource:///org/gnome/shell/ui/extensionSystem.js:365 (7effc4c501f0 @ 67)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #15   5599232ec638 i   resource:///org/gnome/shell/ui/extensionSystem.js:373 (7effc4c50280 @ 41)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #16   5599232ec5a8 i   resource:///org/gnome/shell/ui/main.js:225 (7effc4ed2ca0 @ 1181)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #17   5599232ec520 i   resource:///org/gnome/shell/ui/main.js:127 (7effc4ed2b80 @ 201)
 3ๆœˆ 14 19:15:53 A285 org.gnome.Shell.desktop[30874]: #18   5599232ec4a8 i   <main>:1 (7effc4e851f0 @ 48)

I'm bit lost here, not really familiar with JS or gnome-shell stuff, would appreciate some help...

confirmed working with @shemgp's fix.

Hello guys,

the patch did the trick for me, feel free to integrate into codebase.

Cheers

--- extension.js    2019-03-29 09:17:41.000000000 +1000
+++ /usr/share/gnome-shell/extensions/[email protected]/extension.js  2019-03-29 12:42:46.836506249 +1000
@@ -255,12 +255,10 @@
     },
 });

-const smDialog = Lang.Class({
-    Name: 'SystemMonitor.smDialog',
-    Extends: ModalDialog.ModalDialog,
+class smDialog extends ModalDialog.ModalDialog {

-    _init: function () {
-        this.parent({styleClass: 'prompt-dialog'});
+    constructor() {
+        super({styleClass: 'prompt-dialog'});
         let mainContentBox = new St.BoxLayout({style_class: 'prompt-dialog-main-layout',
             vertical: false});
         this.contentLayout.add(mainContentBox,
@@ -296,9 +294,9 @@
                 key: Clutter.Escape
             }
         ]);
-    },
+    }

-});
+}

 const Chart = new Lang.Class({
     Name: 'SystemMonitor.Chart',
@@ -642,45 +640,39 @@
     }
 });

-const TipItem = new Lang.Class({
-    Name: 'SystemMonitor.TipItem',
-    Extends: PopupMenu.PopupBaseMenuItem,
-
-    _init: function () {
-        PopupMenu.PopupBaseMenuItem.prototype._init.call(this);
+class TipItem extends PopupMenu.PopupBaseMenuItem {
+    constructor() {
+        super();
         this.actor.remove_style_class_name('popup-menu-item');
         this.actor.add_style_class_name('sm-tooltip-item');
     }
-});
+}
+
+class TipMenu extends PopupMenu.PopupMenuBase {

-const TipMenu = new Lang.Class({
-    Name: 'SystemMonitor.TipMenu',
-    Extends: PopupMenu.PopupMenuBase,
-
-    _init: function (sourceActor) {
-        // PopupMenu.PopupMenuBase.prototype._init.call(this, sourceActor, 'sm-tooltip-box');
-        this.parent(sourceActor, 'sm-tooltip-box');
-        this.actor = new Shell.GenericContainer();
-        this.actor.connect('get-preferred-width',
+    constructor (sourceActor) {
+        super(sourceActor, 'sm-tooltip-box');
+        this.actor = new St.Widget();
+        this.connect('get-preferred-width',
             Lang.bind(this, this._boxGetPreferredWidth));
-        this.actor.connect('get-preferred-height',
+        this.connect('get-preferred-height',
             Lang.bind(this, this._boxGetPreferredHeight));
-        this.actor.connect('allocate', Lang.bind(this, this._boxAllocate));
+        this.connect('allocate', Lang.bind(this, this._boxAllocate));
         this.actor.add_actor(this.box);
-    },
-    _boxGetPreferredWidth: function (actor, forHeight, alloc) {
+    }
+    _boxGetPreferredWidth (actor, forHeight, alloc) {
         // let columnWidths = this.getColumnWidths();
         // this.setColumnWidths(columnWidths);

         [alloc.min_size, alloc.natural_size] = this.box.get_preferred_width(forHeight);
-    },
-    _boxGetPreferredHeight: function (actor, forWidth, alloc) {
+    }
+    _boxGetPreferredHeight (actor, forWidth, alloc) {
         [alloc.min_size, alloc.natural_size] = this.box.get_preferred_height(forWidth);
-    },
-    _boxAllocate: function (actor, box, flags) {
+    }
+    _boxAllocate (actor, box, flags) {
         this.box.allocate(box, flags);
-    },
-    _shift: function () {
+    }
+    _shift() {
         // Probably old but works
         let node = this.sourceActor.get_theme_node();
         let contentbox = node.get_content_box(this.sourceActor.get_allocation_box());
@@ -702,8 +694,8 @@
             tipy = allocation.y1 - height; // If it is at the bottom, place the tooltip above instead of below
         }
         this.actor.set_position(tipx, tipy);
-    },
-    open: function (animate) {
+    }
+    open(animate) {
         if (this.isOpen) {
             return;
         }
@@ -713,13 +705,13 @@
         this._shift();
         this.actor.raise_top();
         this.emit('open-state-changed', true);
-    },
-    close: function (animate) {
+    }
+    close (animate) {
         this.isOpen = false;
         this.actor.hide();
         this.emit('open-state-changed', false);
     }
-});
+}

 const TipBox = new Lang.Class({
     Name: 'SystemMonitor.TipBox',

@moorepants @chrisspen I don't think #521 has anything to do with #508, is this auto-reopen on reference?

Ok. My reported symptoms seem to match that posted on the related launchpad bug report.

is this auto-reopen on reference?

I don't know what this means.

updating to current HEAD ( v38-13-g71dd9b2 , or 71dd9b28ba78c68720e98b1650a2fe8222dd0b0b ) works on Ubuntu 19.04 .

I confirm, that it works in ubu-19.04 (GNOME Shell 3.32.2)

@alephnull this bug is fixed, can you please close this issue / thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bendavis78 picture bendavis78  ยท  13Comments

jakethelizard99 picture jakethelizard99  ยท  4Comments

Alexander-Serov picture Alexander-Serov  ยท  9Comments

RafaelQuirino picture RafaelQuirino  ยท  6Comments

Ecron picture Ecron  ยท  12Comments