CrossPlatformPlaying icon indicating copy to clipboard operation
CrossPlatformPlaying copied to clipboard

Error: ENOENT: no such file or directory, lstat

Open ZeddPerm opened this issue 1 year ago • 5 comments

This is an error I got when opening BetterDiscord. I believe this is due to Discord pushing a massive change, and breaking a lot of BetterDiscord Plugins. image image

ZeddPerm avatar Sep 27 '22 03:09 ZeddPerm

+1

Ashesh3 avatar Oct 01 '22 08:10 Ashesh3

I think the plugin's dead unfortunately, at least for now.

The BetterDiscord team apparently haven't ported the net node library when transitioning to electron v17, which is required for Riot, Epic, EA and Minecraft to work.

So unless they change their mind or I can find a workaround or something, it's a no-go for now :(

giorgi-o avatar Oct 02 '22 18:10 giorgi-o

I asked in the BetterDiscord server, and it seems like there are plans to port the net node library into electron v17. https://github.com/BetterDiscord/BetterDiscord/blob/main/preload/src/api/index.js#L43 image

ZeddPerm avatar Oct 03 '22 06:10 ZeddPerm

Just had a look, and indeed you can import the net module using const net = BetterDiscord.net. However it seems to be some sort of chinese clone of the real net.

For example, calling net.createConnection(4242, "tcpbin.com"); returns an object that has all the properties of Socket, but isn't actually a Socket. It has no functions including no write() and on(), required for sending and receiving data.

I'll keep digging but this isn't a drop-in replacement.

Besides, the tls module still hasn't been ported (required for Riot). If net becomes available I could potentially use a third-party lib to handle the tls part, but it's not straightforward at all, and is very much just a last resort.

(thx to retr0 on discord for helping me with this btw)

giorgi-o avatar Oct 03 '22 19:10 giorgi-o

Update: thanks to the incredible retr0, we may have found a workaround. It involves injecting the plugin into the preload script in order to be able to un code in the main process.

On one hand, this seems overkill for just a betterdiscord plugin. But the more I think about it, the more it seems like the only option:

  • In the new electron version, they decided to further isolate contexts, basically breaking the net/tls modules in the render process. Being able to run it in main directly would solve that problem
  • this plugin has is much bigger than the typical plugin, which is usually just a UI change
  • being able to access main would open so many possibilities not possible in renderer, such as browser logins instead of messing with cookies/tokens for example

Overall I think electron has forced our hand in this, by essentially blockading the render process from doing anything more than, well, rendering. Which makes sense from a security perspective, but the alternative would be to ask everyone to install a separate lightweight helper exe, kinda like PreMID.

giorgi-o avatar Oct 04 '22 07:10 giorgi-o