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
11 changes: 8 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
changelog:
- date: 2026-10-13
version: v13.1.1
changes:
- type: bug
text: "Fix the missing `heartbeat` query parameter for the new subscription flow on `handshake` and `receive messages` state."
- date: 2026-10-12
version: v13.1.0
changes:
Expand Down Expand Up @@ -1508,7 +1513,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '13.1.0'
version: '13.1.1'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1524,7 +1529,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v13.1.0.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v13.1.1.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -2195,7 +2200,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v13.1.0/pubnub.13.1.0.js
location: https://github.com/pubnub/javascript/releases/download/v13.1.1/pubnub.13.1.1.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v13.1.1
October 13 2026

#### Fixed
- Fix the missing `heartbeat` query parameter for the new subscription flow on `handshake` and `receive messages` state.

## v13.1.0
October 12 2026

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
npm install pubnub
```
* or download one of our builds from our CDN:
* https://cdn.pubnub.com/sdk/javascript/pubnub.13.1.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.13.1.0.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.13.1.1.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.13.1.1.min.js

> **React Native:** the SDK relies on a global `URL` implementation, which React Native does not
> provide, so it depends on [`react-native-url-polyfill`](https://www.npmjs.com/package/react-native-url-polyfill).
Expand Down
14 changes: 11 additions & 3 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -5613,7 +5613,7 @@
return base.PubNubFile;
},
get version() {
return '13.1.0';
return '13.1.1';
},
getVersion() {
return this.version;
Expand Down Expand Up @@ -10386,7 +10386,7 @@
return `/v2/subscribe/${subscribeKey}/${encodeNames(channels.sort(), ',')}/0`;
}
get queryParameters() {
const { channelGroups, filterExpression, timetoken, region, onDemand } = this
const { channelGroups, filterExpression, timetoken, region, heartbeat, onDemand } = this
.parameters;
const query = { ee: '' };
if (onDemand)
Expand All @@ -10403,6 +10403,8 @@
query['tt'] = timetoken;
if (region)
query['tr'] = region;
if (heartbeat)
query.heartbeat = heartbeat;
return query;
}
}
Expand All @@ -10428,7 +10430,7 @@
return `/v2/subscribe/${subscribeKey}/${encodeNames(channels.sort(), ',')}/0`;
}
get queryParameters() {
const { channelGroups, filterExpression, state, onDemand } = this
const { channelGroups, heartbeat, filterExpression, state, onDemand } = this
.parameters;
const query = { ee: '' };
if (onDemand)
Expand All @@ -10439,6 +10441,8 @@
query['filter-expr'] = filterExpression;
if (state && Object.keys(state).length > 0)
query['state'] = JSON.stringify(state);
if (heartbeat)
query.heartbeat = heartbeat;
return query;
}
}
Expand Down Expand Up @@ -19797,6 +19801,8 @@
// `on-demand` query parameter not required for non-SharedWorker environment.
if (!this._configuration.isSharedWorkerEnabled())
parameters.onDemand = false;
if (!parameters.heartbeat)
parameters.heartbeat = this._configuration.getPresenceTimeout();
const request = new HandshakeSubscribeRequest(Object.assign(Object.assign({}, parameters), { keySet: this._configuration.keySet, crypto: this._configuration.getCryptoModule(), getFileUrl: this.getFileUrl.bind(this) }));
const abortUnsubscribe = parameters.abortSignal.subscribe((err) => {
request.abort('Cancel subscribe handshake request');
Expand Down Expand Up @@ -19828,6 +19834,8 @@
// `on-demand` query parameter not required for non-SharedWorker environment.
if (!this._configuration.isSharedWorkerEnabled())
parameters.onDemand = false;
if (!parameters.heartbeat)
parameters.heartbeat = this._configuration.getPresenceTimeout();
const request = new ReceiveMessagesSubscribeRequest(Object.assign(Object.assign({}, parameters), { keySet: this._configuration.keySet, crypto: this._configuration.getCryptoModule(), getFileUrl: this.getFileUrl.bind(this) }));
const abortUnsubscribe = parameters.abortSignal.subscribe((err) => {
request.abort('Cancel long-poll subscribe request');
Expand Down
2 changes: 1 addition & 1 deletion 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 '13.1.0';
return '13.1.1';
},
getVersion() {
return this.version;
Expand Down
4 changes: 3 additions & 1 deletion lib/core/endpoints/subscriptionUtils/handshake.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HandshakeSubscribeRequest extends subscribe_1.BaseSubscribeRequest {
return `/v2/subscribe/${subscribeKey}/${(0, utils_1.encodeNames)(channels.sort(), ',')}/0`;
}
get queryParameters() {
const { channelGroups, filterExpression, state, onDemand } = this
const { channelGroups, heartbeat, filterExpression, state, onDemand } = this
.parameters;
const query = { ee: '' };
if (onDemand)
Expand All @@ -39,6 +39,8 @@ class HandshakeSubscribeRequest extends subscribe_1.BaseSubscribeRequest {
query['filter-expr'] = filterExpression;
if (state && Object.keys(state).length > 0)
query['state'] = JSON.stringify(state);
if (heartbeat)
query.heartbeat = heartbeat;
return query;
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/core/endpoints/subscriptionUtils/receiveMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ReceiveMessagesSubscribeRequest extends subscribe_1.BaseSubscribeRequest {
return `/v2/subscribe/${subscribeKey}/${(0, utils_1.encodeNames)(channels.sort(), ',')}/0`;
}
get queryParameters() {
const { channelGroups, filterExpression, timetoken, region, onDemand } = this
const { channelGroups, filterExpression, timetoken, region, heartbeat, onDemand } = this
.parameters;
const query = { ee: '' };
if (onDemand)
Expand All @@ -52,6 +52,8 @@ class ReceiveMessagesSubscribeRequest extends subscribe_1.BaseSubscribeRequest {
query['tt'] = timetoken;
if (region)
query['tr'] = region;
if (heartbeat)
query.heartbeat = heartbeat;
return query;
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/core/pubnub-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,8 @@ class PubNubCore {
// `on-demand` query parameter not required for non-SharedWorker environment.
if (!this._configuration.isSharedWorkerEnabled())
parameters.onDemand = false;
if (!parameters.heartbeat)
parameters.heartbeat = this._configuration.getPresenceTimeout();
const request = new handshake_1.HandshakeSubscribeRequest(Object.assign(Object.assign({}, parameters), { keySet: this._configuration.keySet, crypto: this._configuration.getCryptoModule(), getFileUrl: this.getFileUrl.bind(this) }));
const abortUnsubscribe = parameters.abortSignal.subscribe((err) => {
request.abort('Cancel subscribe handshake request');
Expand Down Expand Up @@ -1499,6 +1501,8 @@ class PubNubCore {
// `on-demand` query parameter not required for non-SharedWorker environment.
if (!this._configuration.isSharedWorkerEnabled())
parameters.onDemand = false;
if (!parameters.heartbeat)
parameters.heartbeat = this._configuration.getPresenceTimeout();
const request = new receiveMessages_1.ReceiveMessagesSubscribeRequest(Object.assign(Object.assign({}, parameters), { keySet: this._configuration.keySet, crypto: this._configuration.getCryptoModule(), getFileUrl: this.getFileUrl.bind(this) }));
const abortUnsubscribe = parameters.abortSignal.subscribe((err) => {
request.abort('Cancel long-poll subscribe request');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pubnub",
"version": "13.1.0",
"version": "13.1.1",
"author": "PubNub <support@pubnub.com>",
"description": "PubNub SDK for JavaScript. Publish/subscribe messaging over HTTP long-poll with server-assigned message ordering, channel occupancy via Here Now, and message history through Message Persistence.",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const makeConfiguration = (
return base.PubNubFile;
},
get version(): string {
return '13.1.0';
return '13.1.1';
},
getVersion(): string {
return this.version;
Expand Down
3 changes: 2 additions & 1 deletion src/core/endpoints/subscriptionUtils/handshake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ export class HandshakeSubscribeRequest extends BaseSubscribeRequest {
}

protected get queryParameters(): Query {
const { channelGroups, filterExpression, state, onDemand } = this
const { channelGroups, heartbeat, filterExpression, state, onDemand } = this
.parameters as unknown as Subscription.CancelableSubscribeParameters;
const query: Query = { ee: '' };

if (onDemand) query['on-demand'] = 1;
if (channelGroups && channelGroups.length > 0) query['channel-group'] = channelGroups.sort().join(',');
if (filterExpression && filterExpression.length > 0) query['filter-expr'] = filterExpression;
if (state && Object.keys(state).length > 0) query['state'] = JSON.stringify(state);
if (heartbeat) query.heartbeat = heartbeat;

return query;
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/endpoints/subscriptionUtils/receiveMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ReceiveMessagesSubscribeRequest extends BaseSubscribeRequest {
}

protected get queryParameters(): Query {
const { channelGroups, filterExpression, timetoken, region, onDemand } = this
const { channelGroups, filterExpression, timetoken, region, heartbeat, onDemand } = this
.parameters as unknown as Subscription.CancelableSubscribeParameters;
const query: Query = { ee: '' };

Expand All @@ -49,6 +49,7 @@ export class ReceiveMessagesSubscribeRequest extends BaseSubscribeRequest {
if (timetoken && timetoken !== '0' && timetoken.length > 0) query['tt'] = timetoken;
} else if (timetoken && timetoken > 0) query['tt'] = timetoken;
if (region) query['tr'] = region;
if (heartbeat) query.heartbeat = heartbeat;

return query;
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/pubnub-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,7 @@ export class PubNubCore<
if (process.env.SUBSCRIBE_EVENT_ENGINE_MODULE !== 'disabled') {
// `on-demand` query parameter not required for non-SharedWorker environment.
if (!this._configuration.isSharedWorkerEnabled()) parameters.onDemand = false;
if (!parameters.heartbeat) parameters.heartbeat = this._configuration.getPresenceTimeout();

const request = new HandshakeSubscribeRequest({
...parameters,
Expand Down Expand Up @@ -1984,6 +1985,7 @@ export class PubNubCore<
if (process.env.SUBSCRIBE_EVENT_ENGINE_MODULE !== 'disabled') {
// `on-demand` query parameter not required for non-SharedWorker environment.
if (!this._configuration.isSharedWorkerEnabled()) parameters.onDemand = false;
if (!parameters.heartbeat) parameters.heartbeat = this._configuration.getPresenceTimeout();

const request = new ReceiveMessagesSubscribeRequest({
...parameters,
Expand Down
13 changes: 12 additions & 1 deletion test/integration/endpoints/subscribe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe('subscribe endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
ee: '',
heartbeat: '300',
Comment thread
mohitpubnub marked this conversation as resolved.
})
.reply(
200,
Expand All @@ -79,6 +80,7 @@ describe('subscribe endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
ee: '',
heartbeat: '300',
tt: cursorTimetoken,
tr: 1,
})
Expand Down Expand Up @@ -116,7 +118,7 @@ describe('subscribe endpoints', () => {
});

it('supports addition of multiple channels / channel groups', (done) => {
// Event Engine: handshake uses `ee` (no `heartbeat` on subscribe); `m` on handshake is ignored.
// Event Engine: handshake uses `ee` and `heartbeat` (presence timeout); `m` on handshake is ignored.
// Long-poll receive must be mocked after handshake.
const cursorTimetoken = '14607577960932487';

Expand All @@ -128,6 +130,7 @@ describe('subscribe endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
ee: '',
heartbeat: '300',
})
.reply(
200,
Expand All @@ -143,6 +146,7 @@ describe('subscribe endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
ee: '',
heartbeat: '300',
tt: cursorTimetoken,
tr: 1,
})
Expand Down Expand Up @@ -193,6 +197,7 @@ describe('subscribe endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
ee: '',
heartbeat: '300',
})
.reply(
200,
Expand All @@ -208,6 +213,7 @@ describe('subscribe endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
ee: '',
heartbeat: '300',
tt: cursorTimetoken,
tr: 1,
})
Expand Down Expand Up @@ -255,6 +261,7 @@ describe('subscribe endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
ee: '',
heartbeat: '300',
})
.reply(
200,
Expand All @@ -270,6 +277,7 @@ describe('subscribe endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
ee: '',
heartbeat: '300',
tt: cursorTimetoken,
tr: 1,
})
Expand Down Expand Up @@ -442,6 +450,7 @@ describe('subscribe endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
ee: '',
heartbeat: '300',
})
.reply(
200,
Expand All @@ -457,6 +466,7 @@ describe('subscribe endpoints', () => {
tt: cursorHandshake,
tr: 1,
ee: '',
heartbeat: '300',
})
.reply(
200,
Expand All @@ -472,6 +482,7 @@ describe('subscribe endpoints', () => {
tt: cursorAfterInterval,
tr: 1,
ee: '',
heartbeat: '300',
})
.reply(200, `{"t":{"t":"${cursorAfterInterval}","r":1},"m":[]}`, { 'content-type': 'text/javascript' })
.persist();
Expand Down
Loading
Loading