hardpixel / unite-shell

Unite is an extension that makes GNOME Shell look like Ubuntu Unity Shell.
GNU General Public License v3.0
929 stars 62 forks source link

RangeError: too many function arguments, getFileContents@handlers.js:54:19 #378

Open scarlion1 opened 11 hours ago

scarlion1 commented 11 hours ago

I'm not sure which version of Unite I previously had, it was several versions behind but it worked great until recently when Gnome upgrades were applied and Unite v80 was installed/upgraded.  This was shown in the Extensions list: Kazam_screenshot_00000

and this was in the system log:

gnome-shell[2585]: 
Extension unite@hardpixel.eu: 
RangeError: too many function arguments

Stack trace:
  getFileContents@file:///home/scar/.local/share/gnome-shell/extensions/unite@hardpixel.eu/handlers.js:54:19
  resetGtkStyles/<@file:///home/scar/.local/share/gnome-shell/extensions/unite@hardpixel.eu/handlers.js:72:32
  resetGtkStyles@file:///home/scar/.local/share/gnome-shell/extensions/unite@hardpixel.eu/handlers.js:70:16
  enable@file:///home/scar/.local/share/gnome-shell/extensions/unite@hardpixel.eu/extension.js:16:14
  _callExtensionEnable@resource:///org/gnome/shell/ui/extensionSystem.js:266:38
  loadExtension@resource:///org/gnome/shell/ui/extensionSystem.js:478:32
  async*_loadExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:786:24
  async*_enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:792:48
  _sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:827:20
  async*init@resource:///org/gnome/shell/ui/extensionSystem.js:76:14
  _initializeUI@resource:///org/gnome/shell/ui/main.js:303:22
  start@resource:///org/gnome/shell/ui/main.js:175:11
  @resource:///org/gnome/shell/ui/init.js:12:47
  @resource:///org/gnome/shell/ui/init.js:21:20

To Reproduce Steps to reproduce the behavior:

  1. wget https://github.com/hardpixel/unite-shell/releases/download/v80/unite-v80.zip
  2. gnome-extensions install unite-v80.zip

Environment:

I checked getFileContents@handlers.js:54:19 and rewrote that to:

    51   │ function getFileContents(path) {
    52   │   if (fileExists(path)) {
    53   │     const contents = GLib.file_get_contents(path);
  **54   │     const decoder = new TextDecoder('utf-8');
  ++55   │     return decoder.decode(contents[1]);
    56   │   } else {
    57   │     return '';
    58   │   }
    59   │ }

Now extension works again for me 🎉

According to experts, TextDecoder is more robust and offers a better approach for converting large buffers or arrays to strings, and is a more memory-efficient way to handle large data. 🤷💫

jonian commented 5 hours ago

Thanks for the detailed report @scarlion1! Would you like to make a PR for this?