Skip to content

Commit

Permalink
fix: let destroy rpc in the very end of login()
Browse files Browse the repository at this point in the history
I have infinite "Encountered following error while trying to login: Error: Could not connect" errors while trying to use the extension. And I don't get "Reconnect to Discord" text in status bar icon + error message in the bottom right corner. As I figured there is a problem inside of rpc.destroy() or in it's usage.

So I moved rpc.destroy() call+await to end of catch block to make important actions happen before struck.

I don't know the library for very much but I think it may help. Up to you, iCrawl.

P.S. Particullar error what gives me login attempt is simillar to this one discord/discord-rpc#337 . Trouble inside of rpc library? Should I try older version of your extension? Thank you
  • Loading branch information
A-F-Kay committed Aug 12, 2021
1 parent 43c35e1 commit 65d0fc1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ async function login() {
} catch (error) {
log(LogLevel.Error, `Encountered following error while trying to login:\n${error as string}`);
cleanUp();
await rpc.destroy();
if (!config[CONFIG_KEYS.SuppressNotifications]) {
// @ts-ignore
if (error?.message?.includes('ENOENT')) void window.showErrorMessage('No Discord client detected');
else void window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error as string}`);
}
statusBarIcon.text = '$(pulse) Reconnect to Discord';
statusBarIcon.command = 'discord.reconnect';

await rpc.destroy();
}
}

Expand Down

0 comments on commit 65d0fc1

Please sign in to comment.