coc-discord-rpc: Cannot enable the extension

I just installed this coc extension and its not working. When I try to enable the extension, it throws this error.

Error:

[coc.nvim]: UnhandledRejection: TypeError: Cannot read property 'write' of null
UnhandledRejection: TypeError: Cannot read propery 'write' of null

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 27 (12 by maintainers)

Most upvoted comments

For anyone else searching, I went into /.config/coc/extensions/node_modules/coc-discord-rpc/lib/index.js and changed line 3046 from return ${prefix.replace(/\/$/, '')}/discord-ipc-${id}; to return /var/folders/g3/znz8yyl55ls27thh9l56x6rr0000gn/T/discord-ipc-${id};which was what it returned when I typed $ find /private/var/folders -name "*discord-ipc*" 2> /dev/null.

See that’s what makes no sense, you say it doesn’t support Mac OSX. I would say otherwise, because discord-vscode, which works perfectly on my machine, relies on discordjs/RPC as well, meaning it must support Mac OSX. That would mean it is something that you need to fix in the extension.

I have the same issue, discord-vscode works as is, but not coc-discord-rpc.

I edited the error message to print the id and path of getRPC

coc-nvivm.log:

2021-02-01T16:09:43.894 INFO (pid:44049) [coc-discord-rpc] - === Extension activated ===
2021-02-01T16:09:43.895 INFO (pid:44049) [coc-discord-rpc] - Extension Name: leonardssh.coc-discord-rpc.
2021-02-01T16:09:43.896 INFO (pid:44049) [coc-discord-rpc] - Extension Version: 4.0.0-38e0d4d6.
2021-02-01T16:09:43.900 ERROR (pid:44049) [coc-discord-rpc] - Error: Could not connect id: 10 path: /var/folders/gh/55y8x3qd72l3w9ph4c5knj3c0000gn/T/nvimRKrfDj/discord-ipc-10
    at Socket.onerror (/Users/john/.config/coc/extensions/node_modules/coc-discord-rpc/lib/index.js:3056:16)
    at Object.onceWrapper (node:events:483:26)
    at Socket.emit (node:events:376:20)
    at emitErrorNT (node:internal/streams/destroy:188:8)
    at emitErrorCloseNT (node:internal/streams/destroy:153:3)
    at processTicksAndRejections (node:internal/process/task_queues:80:21)

The discord-ipc path on my machine is different:

$ find /private/var/folders -name "*discord-ipc*" 2> /dev/null
/private/var/folders/gh/55y8x3qd72l3w9ph4c5knj3c0000gn/T/discord-ipc-0

macOS 11.1 (Big Sur) NVIM v0.5.0-dev+1059-g55add1c1c coc-discord-rpc 4.0.0

Ok, sounds good. Hopefully it works. Well see I guess.

See that’s what makes no sense, you say it doesn’t support Mac OSX. I would say otherwise, because discord-vscode, which works perfectly on my machine, relies on discordjs/RPC as well, meaning it must support Mac OSX. That would mean it is something that you need to fix in the extension.

Welp, nvm then. Also it seems named pipes in windows aren’t communicable through WSL, so this wont work plugin wont work on WSL. Anyway, for better error handling you should fix the dispose function 😃

I’m guessing @MrDogeBro is running WSL, because I stumbled upon this issue myself too. There seems to be an issue connecting to the named pipe in \?\pipe\discord-ipc-0, I’m getting an ECONNREFUSED when attempting to connect on my own. I’ll try and figure that out.

In the meantime, one should also put up a pull request on Discord’s RPC implementation, right here to check for WSL as well (it is as simple as checking if the string ‘microsoft’ is inside the platform info).

The last issue is the fact that you dispose the client on error:

		try {
			await client.connect();
		} catch (error) {
			log(error, LogLevel.Err);
			void client.dispose();
		}

And that calls the rpc.destroy function, which attempts to write on the uninitialized socket and throws the original error 😄