coc-discord-rpc
coc-discord-rpc copied to clipboard
fix: Cannot read properties of null reading "write"
Cause: This was caused by 2 issue stacking over each other
- neovim OR coc set the
$TMPDIRto/var/folders/tg/**/T/nvim** - macOS returning
/var/folders/tg/**/T/**via$TMPDIRwhen the real tmp directory is/private/var/folders/tg/**/T/**
Fix:
What we do is we loop through the path variable that discord-rpc search and fix the path,
1. Loop through the path variable
2. Turn the path into real path
3. check if it contains nvim
4. if yes, get the parent directory
5. if no, continue
6. set that variable to modified one
Note:
- This was tested on a macOS machine, running on macOS 12.5, This still need to be tested on linux machine too.
- on macOS,
/varis a symlink to/private/var, i am not sure ifnetpackage can handle symlink properly, so the i did thefs.realPath, I am not taking any risk either.
Fixes #59 Fixes #56
Before fix:

After fix:

Discord IPC Path:

Thanks for this PR, I'm glad you found a solution to this problem, I'm going to make a Linux VM environment so I can test it too.
I'll keep this PR open until we see if it's right.
I gonna test this on an Arch Linux VM with KDE Plasma and SDDM.
~~Works great.
~~
Nevermind, It work without the patch.
Ah... discord-ipc-{number} in this case is inside $XDG_RUNTIME_DIR/, which we have no problem with, BUT HOWEVER
TMPDIR is wrong here, Which might explain why people who are using X doesn't have the error.
Ah...
discord-ipc-{number}in this case is insideXDG_RUNTIME_DIR, which we have no problem with, BUT HOWEVER![]()
TMPDIRis wrong here, Which might explain why people who are usingXdoesn't have the error.
It makes perfect sense.
Trying this on Wayland version of plasma.
My assumption are correct.

Yup! This patch fix it!

Conclusion:
discord-rpc will breaks under non-x display server with coc / neovim.
Why? coc / neovim set $TMPDIR / $TMP / $TEMP to $TEMP_DIR/nvim**.
Alright, I got tired of discordjs/RPC, I made my own fork of discordjs/RPC that's up to date, use typescript and can specify your own way to find the ipc path.
If you want, I can port to my discord-rpc for this project in separate PR.
A PR in this regard would be welcome. I also want to port my vscode extension to your discord-rpc fork.
Alright! I just need someone to test if the extension works under Snap version of discord, It's confirmed to work on macOS, Windows and non-snap discord on linux.
Yep, the thing works with snap versions of discord.
Thank you for your work @xhayper!