Repository navigation
fix(core): stabilize connection lifecycle and presence for v1.3.0 - #6
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
StatusCode v1.3.0 — Stability Release
Stabilization release targeting every defect found in v1.2.0's connection lifecycle, idle handling, and presence payload. The headline fix: reconnecting after Discord quits, restarts, or a manual "Reconnect" never actually worked in v1.2.0 — it was structurally impossible.
🔴 Critical
Reconnect was permanently broken after the first disconnect
Reading the vendored
discord-rpc4.0.1 source confirmed the root cause: the library memoizes its internal connect promise and never resets it after the transport closes (RPCClient.connect()returns the settled_connectPromiseforever, anddestroy()only closes the socket).The consequences in v1.2.0, all fixed:
connection closedimmediately — reconnect could never succeed.connectedwhile holding a dead socket, then looped forever between fake successes andsetActivityfailures. This is why presence never came back after Discord restarted.Fix:
DiscordClientnow creates a fresh RPC client instance for every connection attempt (with its event handlers attached per instance, so late events from a discarded client cannot corrupt the next attempt's state), destroys the previous one safely, and serializes concurrent logins — simultaneous connect calls (startup retry, status-bar click, config change) now share one in-flight attempt instead of opening competing IPC connections.🟡 Reliability & correctness
disconnectedevent no longer flips the status bar to "Disconnected" and schedules a reconnect against a healthy connection. Intentional disconnects suppress the callback entirely, so the status bar stays "Disabled" after a disable.login()now destroys the half-connected client before rethrowing, so its transport can't linger into the next attempt.statuscode.reconnectIntervalchanges were ignored while running — the retry loop restarts on config change so a new interval takes effect immediately.🟢 Presence accuracy
recordActivity(true))..gitsuffix shown in presence —owner/repo.gitremotes now display asowner/repo.git://andhttp://remotes are normalized tohttps://and trailing slashes stripped, so the clickable "View Repository" button always opens.Files changed
src/discord-client.tssrc/activity-manager.tssrc/util.tsextractRepoName/toGitHubHttpsUrlparsing fixes;truncateDiscordText+DISCORD_TEXT_LIMITsrc/extension.tssrc/test/util.test.tspackage.json