Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
---
changelog:
- date: 2026-11-24
version: v14.0.1
changes:
- type: bug
text: "NodeTransport now closes an h2 session once it has had no queued or running requests for idle time, or for keepAliveSettings.timeout duration when keepAlive is on."
- type: bug
text: "Fix issue with unsubscribe method not releasing channel in case of zero active subscription reference."
- date: 2026-11-17
version: v14.0.0
changes:
Expand Down Expand Up @@ -1540,7 +1547,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '14.0.0'
version: '14.0.1'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1556,7 +1563,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v14.0.0.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v14.0.1.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -2227,7 +2234,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v14.0.0/pubnub.14.0.0.js
location: https://github.com/pubnub/javascript/releases/download/v14.0.1/pubnub.14.0.1.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v14.0.1
November 24 2026

#### Fixed
- NodeTransport now closes an h2 session once it has had no queued or running requests for idle time, or for keepAliveSettings.timeout duration when keepAlive is on.
- Fix issue with unsubscribe method not releasing channel in case of zero active subscription reference.

## v14.0.0
November 17 2026

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ npm install pubnub

Or download one of our builds from our CDN:

- https://cdn.pubnub.com/sdk/javascript/pubnub.14.0.0.js
- https://cdn.pubnub.com/sdk/javascript/pubnub.14.0.0.min.js
- https://cdn.pubnub.com/sdk/javascript/pubnub.14.0.1.js
- https://cdn.pubnub.com/sdk/javascript/pubnub.14.0.1.min.js

For other installation methods, see [environment setup](https://www.pubnub.com/docs/sdks/javascript/environment-setup).

Expand Down
51 changes: 17 additions & 34 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -1508,25 +1508,6 @@
const encodedNames = names.map((name) => encodeString(name));
return encodedNames.length ? encodedNames.join(',') : (defaultString !== null && defaultString !== void 0 ? defaultString : '');
};
/**
* @internal
*/
const removeSingleOccurrence = (source, elementsToRemove) => {
const removed = Object.fromEntries(elementsToRemove.map((prop) => [prop, false]));
return source.filter((e) => {
if (elementsToRemove.includes(e) && !removed[e]) {
removed[e] = true;
return false;
}
return true;
});
};
/**
* @internal
*/
const findUniqueCommonElements = (a, b) => {
return [...a].filter((value) => b.includes(value) && a.indexOf(value) === a.lastIndexOf(value) && b.indexOf(value) === b.lastIndexOf(value));
};
/**
* Transform query key / value pairs to the string.
*
Expand Down Expand Up @@ -4950,7 +4931,7 @@
return base.PubNubFile;
},
get version() {
return '14.0.0';
return '14.0.1';
},
getVersion() {
return this.version;
Expand Down Expand Up @@ -9484,8 +9465,10 @@
const hasNewChannels = channels === null || channels === void 0 ? void 0 : channels.some((channel) => !this.channels.includes(channel));
const hasNewGroups = channelGroups === null || channelGroups === void 0 ? void 0 : channelGroups.some((group) => !this.groups.includes(group));
const hasNewSubscriptions = hasNewChannels || hasNewGroups;
this.channels = [...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])];
this.groups = [...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])];
// Channels and groups are tracked as a set. Reference counting for entities shared by several subscriptions is done
// by the PubNub client, which calls `unsubscribe` only when no active subscription uses them anymore.
this.channels = Array.from(new Set([...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])]));
this.groups = Array.from(new Set([...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])]));
if (withPresence) {
this.channels.map((c) => this.channels.push(`${c}-pnpres`));
this.groups.map((g) => this.groups.push(`${g}-pnpres`));
Expand Down Expand Up @@ -9526,18 +9509,18 @@
}
}
unsubscribe({ channels = [], channelGroups = [] }) {
const filteredChannels = removeSingleOccurrence(this.channels, [
...channels,
...channels.map((c) => `${c}-pnpres`),
]);
const filteredGroups = removeSingleOccurrence(this.groups, [
...channelGroups,
...channelGroups.map((c) => `${c}-pnpres`),
]);
if (new Set(this.channels).size !== new Set(filteredChannels).size ||
new Set(this.groups).size !== new Set(filteredGroups).size) {
const channelsToLeave = findUniqueCommonElements(this.channels, channels);
const groupsToLeave = findUniqueCommonElements(this.groups, channelGroups);
// A name which already is a presence channel or group (`<name>-pnpres`) doesn't get the suffix a second time.
const withPresenceNames = (names) => [
...names,
...names.filter((name) => !name.endsWith('-pnpres')).map((name) => `${name}-pnpres`),
];
const channelsToRemove = withPresenceNames(channels);
const groupsToRemove = withPresenceNames(channelGroups);
const filteredChannels = this.channels.filter((c) => !channelsToRemove.includes(c));
const filteredGroups = this.groups.filter((g) => !groupsToRemove.includes(g));
if (filteredChannels.length !== this.channels.length || filteredGroups.length !== this.groups.length) {
const channelsToLeave = Array.from(new Set(this.channels.filter((c) => channels.includes(c))));
const groupsToLeave = Array.from(new Set(this.groups.filter((g) => channelGroups.includes(g))));
if (this.dependencies.presenceState) {
channelsToLeave === null || channelsToLeave === void 0 ? void 0 : channelsToLeave.forEach((c) => delete this.dependencies.presenceState[c]);
groupsToLeave === null || groupsToLeave === void 0 ? void 0 : groupsToLeave.forEach((g) => delete this.dependencies.presenceState[g]);
Expand Down
4 changes: 2 additions & 2 deletions dist/web/pubnub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/core/components/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
return base.PubNubFile;
},
get version() {
return '14.0.0';
return '14.0.1';
},
getVersion() {
return this.version;
Expand Down
23 changes: 1 addition & 22 deletions lib/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.encryptMessagePayload = exports.messageFingerprint = exports.adjustedTimetokenBy = exports.referenceSubscribeTimetoken = exports.subscriptionTimetokenFromReference = exports.queryStringFromObject = exports.findUniqueCommonElements = exports.removeSingleOccurrence = exports.encodeNames = exports.encodeString = exports.isSensitiveLogKey = exports.SENSITIVE_LOG_KEYS = void 0;
exports.encryptMessagePayload = exports.messageFingerprint = exports.adjustedTimetokenBy = exports.referenceSubscribeTimetoken = exports.subscriptionTimetokenFromReference = exports.queryStringFromObject = exports.encodeNames = exports.encodeString = exports.isSensitiveLogKey = exports.SENSITIVE_LOG_KEYS = void 0;
const base64_codec_1 = require("./components/base64_codec");
/**
* Object log property names that must never appear in SDK logs.
Expand Down Expand Up @@ -64,27 +64,6 @@ const encodeNames = (names, defaultString) => {
return encodedNames.length ? encodedNames.join(',') : (defaultString !== null && defaultString !== void 0 ? defaultString : '');
};
exports.encodeNames = encodeNames;
/**
* @internal
*/
const removeSingleOccurrence = (source, elementsToRemove) => {
const removed = Object.fromEntries(elementsToRemove.map((prop) => [prop, false]));
return source.filter((e) => {
if (elementsToRemove.includes(e) && !removed[e]) {
removed[e] = true;
return false;
}
return true;
});
};
exports.removeSingleOccurrence = removeSingleOccurrence;
/**
* @internal
*/
const findUniqueCommonElements = (a, b) => {
return [...a].filter((value) => b.includes(value) && a.indexOf(value) === a.lastIndexOf(value) && b.indexOf(value) === b.lastIndexOf(value));
};
exports.findUniqueCommonElements = findUniqueCommonElements;
/**
* Transform query key / value pairs to the string.
*
Expand Down
31 changes: 16 additions & 15 deletions lib/event-engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const dispatcher_1 = require("./dispatcher");
const utils_1 = require("../core/utils");
const core_1 = require("./core");
const categories_1 = __importDefault(require("../core/constants/categories"));
const utils = __importStar(require("../core/utils"));
const events = __importStar(require("./events"));
/**
* Subscribe Event Engine Core.
Expand Down Expand Up @@ -96,8 +95,10 @@ class EventEngine {
const hasNewChannels = channels === null || channels === void 0 ? void 0 : channels.some((channel) => !this.channels.includes(channel));
const hasNewGroups = channelGroups === null || channelGroups === void 0 ? void 0 : channelGroups.some((group) => !this.groups.includes(group));
const hasNewSubscriptions = hasNewChannels || hasNewGroups;
this.channels = [...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])];
this.groups = [...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])];
// Channels and groups are tracked as a set. Reference counting for entities shared by several subscriptions is done
// by the PubNub client, which calls `unsubscribe` only when no active subscription uses them anymore.
this.channels = Array.from(new Set([...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])]));
this.groups = Array.from(new Set([...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])]));
if (withPresence) {
this.channels.map((c) => this.channels.push(`${c}-pnpres`));
this.groups.map((g) => this.groups.push(`${g}-pnpres`));
Expand Down Expand Up @@ -138,18 +139,18 @@ class EventEngine {
}
}
unsubscribe({ channels = [], channelGroups = [] }) {
const filteredChannels = utils.removeSingleOccurrence(this.channels, [
...channels,
...channels.map((c) => `${c}-pnpres`),
]);
const filteredGroups = utils.removeSingleOccurrence(this.groups, [
...channelGroups,
...channelGroups.map((c) => `${c}-pnpres`),
]);
if (new Set(this.channels).size !== new Set(filteredChannels).size ||
new Set(this.groups).size !== new Set(filteredGroups).size) {
const channelsToLeave = utils.findUniqueCommonElements(this.channels, channels);
const groupsToLeave = utils.findUniqueCommonElements(this.groups, channelGroups);
// A name which already is a presence channel or group (`<name>-pnpres`) doesn't get the suffix a second time.
const withPresenceNames = (names) => [
...names,
...names.filter((name) => !name.endsWith('-pnpres')).map((name) => `${name}-pnpres`),
];
const channelsToRemove = withPresenceNames(channels);
const groupsToRemove = withPresenceNames(channelGroups);
const filteredChannels = this.channels.filter((c) => !channelsToRemove.includes(c));
const filteredGroups = this.groups.filter((g) => !groupsToRemove.includes(g));
if (filteredChannels.length !== this.channels.length || filteredGroups.length !== this.groups.length) {
const channelsToLeave = Array.from(new Set(this.channels.filter((c) => channels.includes(c))));
const groupsToLeave = Array.from(new Set(this.groups.filter((g) => channelGroups.includes(g))));
if (this.dependencies.presenceState) {
channelsToLeave === null || channelsToLeave === void 0 ? void 0 : channelsToLeave.forEach((c) => delete this.dependencies.presenceState[c]);
groupsToLeave === null || groupsToLeave === void 0 ? void 0 : groupsToLeave.forEach((g) => delete this.dependencies.presenceState[g]);
Expand Down
11 changes: 11 additions & 0 deletions lib/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ class PubNub extends pubnub_common_1.PubNubCore {
this.nodeTransport.setProxy(configuration);
this.reconnect();
}
/**
* Unsubscribe from all channels and groups.
*
* Connections held by the client are released once pending requests (including the presence `leave`) complete.
*
* @param [isOffline] - Whether `offline` presence should be notified or not.
*/
destroy(isOffline = false) {
super.destroy(isOffline);
this.nodeTransport.releaseConnections();
}
}
/**
* Data encryption / decryption module constructor.
Expand Down
Loading
Loading