Skip to content

Enable transport-level retry for subscribe and retry related adjustments - #470

Merged
parfeon merged 5 commits into
masterfrom
fix/subscribe-transport-retry
Mar 23, 2026
Merged

Enable transport-level retry for subscribe and retry related adjustments#470
parfeon merged 5 commits into
masterfrom
fix/subscribe-transport-retry

Conversation

@parfeon

@parfeon parfeon commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

fix(retry-policy): fix excluded endpoints lost after copy

Fix PNRequestRetryConfiguration copyWithZone not copying excludedEndpoints, causing all endpoint groups to become eligible for retry after PNConfiguration copy.

fix(subscribe): enable transport-level retry

Remove hardcoded retriable = NO from PNSubscribeRequest so transport-level retry configuration is applied to subscribe long-poll requests.

fix(subscribe): prevent duplicate subscribe loops

Add subscribeCycleGeneration counter to PNSubscriber to detect and discard stale continuation calls dispatched asynchronously before a new subscribe cycle started.

refactor(file-sharing): prevent retry of file upload requests

Add retriable = NO to PNFileUploadRequest because body streams cannot be rewound after a partial send.

refactor(presence): prevent retry of heartbeat requests

Add request method override with retriable = NO to PNPresenceHeartbeatRequest because presence heartbeat has its own timer-based periodic mechanism.

refactor(subscribe): remove reachability ping module

Delete PNReachability class and remove references from PubNub.podspec and Framework project in favor of transport-level retry for network recovery.

BREAKING CHANGES: Automatic reconnection after prolonged network outage removed; applications must handle PNUnexpectedDisconnectCategory and re-subscribe manually.

build(spm): use custom modulemap and header search paths for SPM compatibility

Update export script to generate a directory umbrella modulemap instead of flat header symlinks. Configure publicHeadersPath and cSettings in Package.swift.

test(retry-policy): add retry configuration tests

Add unit tests for copyWithZone preserving excluded endpoints, default configuration retrying only subscribe, and heartbeat / file upload requests not being retriable.

test(subscribe): add generation counter and retry tests Add unit tests verifying generation counter prevents stale subscribe continuations and transport-level retry works for subscribe requests using NSURLProtocol interception.

Fix `PNRequestRetryConfiguration` `copyWithZone:` not copying `excludedEndpoints`, causing all
endpoint groups to become eligible for retry after `PNConfiguration` copy.

fix(subscribe): enable transport-level retry

Remove hardcoded `retriable = NO` from `PNSubscribeRequest` so transport-level retry configuration
is applied to subscribe long-poll requests.

fix(subscribe): prevent duplicate subscribe loops

Add `subscribeCycleGeneration` counter to `PNSubscriber` to detect and discard stale continuation
calls dispatched asynchronously before a new subscribe cycle started.

refactor(file-sharing): prevent retry of file upload requests

Add `retriable = NO` to `PNFileUploadRequest` because body streams cannot be rewound after a
partial send.

refactor(presence): prevent retry of heartbeat requests

Add `request` method override with `retriable = NO` to `PNPresenceHeartbeatRequest` because
presence heartbeat has its own timer-based periodic mechanism.

refactor(subscribe): remove reachability ping module

Delete `PNReachability` class and remove references from `PubNub.podspec` and Framework project
in favor of transport-level retry for network recovery.

BREAKING CHANGE: Automatic reconnection after prolonged network outage removed; applications must
handle `PNUnexpectedDisconnectCategory` and re-subscribe manually.

build(spm): use custom modulemap and header search paths for SPM compatibility

Update export script to generate a directory umbrella modulemap instead of flat
header symlinks. Configure publicHeadersPath and cSettings in Package.swift.

test(retry-policy): add retry configuration tests

Add unit tests for `copyWithZone:` preserving excluded endpoints, default configuration retrying
only subscribe, and heartbeat / file upload requests not being retriable.

test(subscribe): add generation counter and retry tests
Add unit tests verifying generation counter prevents stale subscribe continuations and
transport-level retry works for subscribe requests using `NSURLProtocol` interception.
@parfeon parfeon self-assigned this Mar 19, 2026
@parfeon
parfeon requested a review from jguz-pubnub as a code owner March 19, 2026 17:36
@parfeon parfeon added status: done This issue is considered resolved. priority: high This PR should be reviewed ASAP. type: fix This PR contains fixes to existing features. type: refactor This PR contains refactored existing features. labels Mar 19, 2026
@pubnub-ops-terraform

pubnub-ops-terraform commented Mar 19, 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.

Comment thread PubNub/Data/Managers/PNSubscriber.m Outdated
Comment on lines +1123 to +1124
NSLog(@"~~~~~> HOD UP");
NSLog(@"~~~~~> HOD UP BOI");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these logs necessary?

@jguz-pubnub
jguz-pubnub self-requested a review March 23, 2026 08:54
@parfeon

parfeon commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

@pubnub-release-bot release

@parfeon
parfeon merged commit b42404e into master Mar 23, 2026
10 checks passed
@parfeon
parfeon deleted the fix/subscribe-transport-retry branch March 23, 2026 16:54
@pubnub-release-bot

Copy link
Copy Markdown

🚀 Release successfully completed 🚀

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

Labels

priority: high This PR should be reviewed ASAP. status: done This issue is considered resolved. type: fix This PR contains fixes to existing features. type: refactor This PR contains refactored existing features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants