Skip to content

Send a leave request on unsubscribe with the default asyncio client - #244

Merged
techwritermat merged 5 commits into
masterfrom
fix/asyncio-unsubscribe-leave
Nov 23, 2026
Merged

techwritermat merged 5 commits into
masterfrom
fix/asyncio-unsubscribe-leave

Conversation

@techwritermat

@techwritermat techwritermat commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

fix(asyncio): send a leave request when unsubscribing with the default client

Unsubscribing with the default PubNubAsyncio client now sends a leave request unless suppress_leave_events is set, as the threaded and legacy asyncio subscription managers already do. The event engine subscription manager used to send it only when enable_presence_heartbeat was on, so the user ID stayed an occupant of the channel until the presence timeout and the other subscribers did not receive its leave presence event.

test: add offline unit tests for the leave request on unsubscribe

The event engine subscription manager, the default for PubNubAsyncio, sent
a leave request only when enable_presence_heartbeat was on. A default client
therefore stayed an occupant of the channel until the presence timeout, and
suppress_leave_events=False (the default) had no effect. The threaded and
legacy asyncio managers send the leave unless suppress_leave_events is set.

Send it directly when the presence engine does not, skip -pnpres channels and
empty operations, and keep suppress_leave_events working. Add offline unit
tests and a live test that checks here_now after the unsubscribe.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pubnub-snyk-universal-prd

pubnub-snyk-universal-prd Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

It needs a keyset that lists a client as an occupant when it subscribes
without presence heartbeats. The keysets of the CI run do not, so the test
failed there although the change works (it passes on a keyset with that
presence setting). The offline unit tests cover the change on any keyset.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
techwritermat and others added 2 commits November 23, 2026 13:30
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@techwritermat

Copy link
Copy Markdown
Contributor Author

@pubnub-release-bot release

@techwritermat
techwritermat merged commit 9f423bb into master Nov 23, 2026
16 of 20 checks passed
@techwritermat
techwritermat deleted the fix/asyncio-unsubscribe-leave branch November 23, 2026 14:32
@pubnub-release-bot

Copy link
Copy Markdown
Contributor

🚀 Release successfully completed 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants