Error when opening preferences from extension PopupMenuItem

Hello, I’m trying to write an extension (keyboard backlight color manager) that has a tray icon with some options:

  • a scalar scale (slider that snaps to integer values)
  • color button selector
  • button to open extension preferences

I’m not sure which widgets to subclass to create the first two.

And while I’m trying to implement the last one, the preferences window opens with a light theme (instead of my system wide dark mode) after a long time and the following warning appears:

Unhandled promise rejection. To suppress this warning, add an error handler to your promise chain with .catch() or a try-catch block around your await expression. Stack trace of the failed promise

Below is a smaller snippet adapted from my code that I’m testing with dbus-run-session gnome-shell --nested --wayland

import { Extension, gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js';
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';

export default class MyExtension extends Extension {
  enable() {
    this._indicator = new PanelMenu.Button(0.0, _(this.metadata.name), false);
    this._indicator.menu.addAction(_("Preferences"), () => this.openPreferences());
    //   ofending code                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Main.panel.addToStatusArea(this.uuid, this._indicator);
  }
}

I tried to search for similar extensions online or extensions that had a similar code, but I couldn’t find any and I’m not sure how to solve this warning. Does anyone knows how to customise these menu items and deal with these promises? Any help is greatly appreciated.