fix(instance): do not clear event subscriptions on disconnect - #187
Open
guipratiko wants to merge 1 commit into
Open
fix(instance): do not clear event subscriptions on disconnect#187guipratiko wants to merge 1 commit into
guipratiko wants to merge 1 commit into
Conversation
Disconnect was wiping Events before persisting. After reconnect the
instance looked connected but CallWebhook built an empty subscription
list (strings.Split("", ",") yields [""]), so every webhook was dropped.
Keep subscriptions and only mark the instance disconnected.
Co-authored-by: Cursor <cursoragent@cursor.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideDisconnect now preserves the instance’s event subscription configuration and updates only its connected state and disconnect reason, preventing reconnects from silently dropping webhook deliveries. Sequence diagram for preserving webhook subscriptions on disconnect and reconnectsequenceDiagram
participant API as Instance API
participant Service as Instance Service
participant Repo as Instance Repository
participant Instance as Instance
participant Webhook as Webhook
API->>Service: Disconnect(instance)
Service->>Instance: UpdateConnected(false, Disconnected by API)
Service->>Repo: UpdateConnected(instance.Id, false, DisconnectReason)
Note over Instance,Repo: Events remains unchanged
API->>Service: Reconnect(instance)
Service->>Repo: Read instance with Events
Service->>Webhook: CallWebhook with preserved event subscriptions
Webhook-->>API: Message webhook delivered
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If this behavior is wrong, retained subscriptions can cause webhooks to be sent after an instance reconnects when they previously would have been dropped. Reverting prevents future sends, but it cannot undo notifications already delivered externally.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Summary
Disconnectwas wipinginstance.Eventsbefore persisting the instance.reconnect/connect, the instance looked connected butCallWebhookbuilt an empty subscription list (strings.Split("", ",")yields[""], which failsIsEventType), so every webhook was dropped.UpdateConnected.Reproduction
events=MESSAGE,CONNECTION,...and a webhook URL.POST /instance/disconnectPOST /instance/reconnect(or connect again)eventsis empty and inbound WhatsApp messages never reach the webhook.Test plan
eventsGET /instance/info/{id}still shows the previouseventsstringMessageconnected=false/ disconnect reason after disconnectMade with Cursor
Summary by Sourcery
Preserve event subscriptions when disconnecting instances so reconnects continue to route webhook events correctly.
Bug Fixes:
Enhancements: