Skip to content

Conversation

@parfeon
Copy link
Contributor

@parfeon parfeon commented Jul 4, 2025

fix(subscription-set): fix issue with global subscription set

Fix the issue with the global subscription set (used for legacy interface support) because of which
unsubscribe with the legacy interface wasn't able to complete the unsubscribe process.

fix(shared-worker): fix rapid subscribe aggregate

Fix the issue because of which rapid subscription (from other PubNub clients in response to received subscribe response) throttling causes delayed channel list change.

feat(shared-worker): emit heartbeat processing status

Depending on client configuration, it will emit status for heartbeat, which has been started by the SharedWorker backup heartbeat timer mechanism.

feat(shared-worker): stop backup heartbeats on 403

Stop heartbeats until the auth key / access token is changed. On change, SharedWorker will send an immediate heartbeat request.

refactor(shared-worker): restart backup heartbeat on explicit heartbeat

Restart the timer of the backup heartbeat if an explicit heartbeat request has been received from the main PubNub client.

refactor(shared-worker): add output of requests processed by the SharedWorker

Modify the log payload for SharedWorker to make it possible to log sent / received requests information to the main browser window (not to the SharedWorker console).

Fix the issue because of which rapid subscription (from other PubNub clients in response to
received subscribe response) throttling causes delayed channel list change.

refactor(shared-worker): add output of requests processed by the `SharedWorker`

Modify the `log` payload for `SharedWorker` to make it possible to log sent / received requests
information to the main browser window (not to the SharedWorker console).
@parfeon parfeon self-assigned this Jul 4, 2025
@parfeon parfeon added status: in progress This issue is being worked on. priority: high This PR should be reviewed ASAP. type: fix This PR contains fixes to existing features. labels Jul 4, 2025
@pubnub-ops-terraform
Copy link

pubnub-ops-terraform commented Jul 4, 2025

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

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Depending on client configuration, it will emit `status` for heartbeat, which has been started by the `SharedWorker` backup heartbeat timer mechanism.

feat(shared-worker): stop `backup` heartbeats on 403

Stop heartbeats until the auth key / access token is changed. On change, `SharedWorker` will send an immediate heartbeat request.

refactor(shared-worker): restart `backup` heartbeat on explicit heartbeat

Restart the timer of the backup heartbeat if an explicit heartbeat request has been received from the main PubNub client.
*
* @default `true`
*/
announceFailedHeartbeats: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

this will help to get more feedback on hb
👍🏻

@mohitpubnub
Copy link
Contributor

mohitpubnub commented Jul 5, 2025

Looks fine so far.
With tab close and subscription changes handling in subscribe and heartbeat requests.

parfeon added 3 commits July 7, 2025 15:41
Fix the issue with the global subscription set (used for legacy interface support) because of which
`unsubscribe` with the legacy interface wasn't able to complete the unsubscribe process.
To avoid confusion in the logs reading where the message about sending the request appears earlier
than it should, move the log output before sending the request.
…clients

Make sure that more clients will receive log messages about request sending (we're limited to a
single client for heartbeat requests).

refactor(shared-worker): change log message when heartbeat impossible for presence-only channels

Change the misleading console message for heartbeat requests, which are scheduled for
presence-only (`-pnpres`).
@parfeon parfeon marked this pull request as ready for review July 10, 2025 06:26
@parfeon parfeon requested a review from seba-aln as a code owner July 10, 2025 06:26
* added karma configuration for sharedworker tests with headless browser,
added tests with edge cases for subscribe/unsubscribe with sharedworker

* fix: shared worker tests to adapt quick subscription aggregation handling compatible behaviour

* test: shared worker subscription aggregation and isolation in message distribution in scenario where messages arrive in one of the aggregated channel entities

* test(shared-worker): added test for token management, to test token change behaviour in share worker active subscription

* test(shared-worker): added message verification to confirm subscription change, added new test to verify resubscribing to same channel with message reecive check

* test(shared-worker): test cleanup, removed debug logs

* test(shared-worker) confirm auth token changes through middleware generated request url

* test: added test to inspect presence behaviour mimicking tab close activities

---------

Co-authored-by: Mohit Tejani <mohit.tejani@Mohits-MacBook-Pro.local>
parfeon added 2 commits July 10, 2025 22:54
…filter

Incorporate a 3-second threshold from the server to the logic that is used to skip heartbeat
requests if it has been sent too soon (because the previous one was not so long ago).
…com:pubnub/javascript into fix/subscribe-aggregate-heartbeats-feedback
// Check whether it is too soon to send request or not.
const leeway = minimumHeartbeatInterval * 0.05 * 1000;

if (minimumHeartbeatInterval - leeway <= 3) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻

parfeon added 2 commits July 11, 2025 10:24
Fix the condition that, in some cases (burst subscribe from registered clients) incorrectly
identified when the initial subscribe REST API response should be patched with catch timetoken.
Re-adjust "backup" heartbeat timer when one of the clients request sent too early after previous
request.
Copy link
Contributor

@mohitpubnub mohitpubnub left a comment

Choose a reason for hiding this comment

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

Works in non EE also now

// than 3 seconds which derived from the server's threshold.
// Leeway can't be applied if actual interval between heartbeat requests is smaller
// than 3 seconds which derived from the server's threshold.
if (minimumHeartbeatInterval - leeway <= 3 || expectedTimestamp - currentTimestamp > leeway) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻

@mohitpubnub
Copy link
Contributor

@pubnub-release-bot release

@mohitpubnub mohitpubnub merged commit 8bf3d6f into master Jul 11, 2025
9 checks passed
@mohitpubnub mohitpubnub deleted the fix/subscribe-aggregate-heartbeats-feedback branch July 11, 2025 14:27
@pubnub-release-bot
Copy link
Contributor

🚀 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: in progress This issue is being worked on. type: fix This PR contains fixes to existing features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants