Skip to content

Commit 729d8f0

Browse files
umair-ablyclaude
andcommitted
DX-1211: fix presence hint capability; move presence/subscribe errors off colliding 93002
Two fixes to the presence.get()/channel.subscribe() missing-mode errors: - Hint correctness (review feedback): the presence hint named a "presence-subscribe" capability that does not exist. Presence delivery is governed by the "subscribe" capability, matching the subscribe-mode hint. - Error-code collision: 93002 is the canonical server code for "namespace needs Mutable Messages" (ably-common errors.json, faqs.ably.com/error-code-93002). presence.get() reused it client-side. Move presence to 91008 (presence block, next to 91005) and channel.subscribe() to 90009 (channel block); 93xxx is the annotations/mutable-messages block. Both codes are new on this unreleased branch, so the renumber is non-breaking. Reserved in ably/ably-common#345. Update the two tests asserting them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ff0cf3d commit 729d8f0

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/common/lib/client/realtimechannel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ class RealtimeChannel extends EventEmitter {
520520
const err = new ErrorInfo({
521521
message:
522522
'The channel was attached without the subscribe mode, so the server will not deliver messages to this listener.',
523-
code: 93003,
523+
code: 90009,
524524
statusCode: 400,
525525
hint: 'Include "subscribe" in the channel modes: realtime.channels.get(name, { modes: ["subscribe", ...] }), or call channel.setOptions({ modes: [...] }) on an existing channel (this triggers a reattach). Alternatively, omit modes entirely and ensure your token/API-key capability permits subscribe on this channel. If you have the Ably CLI installed, `ably auth keys list` shows your key\'s capabilities.',
526526
});

src/common/lib/client/realtimepresence.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ class RealtimePresence extends EventEmitter {
251251
const err = new ErrorInfo({
252252
message:
253253
'The channel was attached without the presence_subscribe mode, so the server has not delivered any members to this client.',
254-
code: 93002,
254+
code: 91008,
255255
statusCode: 400,
256-
hint: 'Include "presence_subscribe" in the channel modes: realtime.channels.get(name, { modes: ["presence_subscribe", ...] }), or call channel.setOptions({ modes: [...] }) on an existing channel (this triggers a reattach). Alternatively, omit modes entirely and ensure your token/API-key capability permits presence-subscribe on this channel. If you have the Ably CLI installed, `ably auth keys list` shows your key\'s capabilities.',
256+
hint: 'Include "presence_subscribe" in the channel modes: realtime.channels.get(name, { modes: ["presence_subscribe", ...] }), or call channel.setOptions({ modes: [...] }) on an existing channel (this triggers a reattach). Alternatively, omit modes entirely and ensure your token/API-key capability permits subscribe on this channel. If you have the Ably CLI installed, `ably auth keys list` shows your key\'s capabilities.',
257257
});
258258
if (this.channel.client.options.strictMode === true) throw err;
259259
Logger.logActionNoStrip(

test/realtime/channel.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, Helper, async
21182118
});
21192119

21202120
describe('subscribe() without subscribe mode', function () {
2121-
it('with strictMode:true, attach resolves but subscribe rejects with 93003 and a subscribe-mode hint', async function () {
2121+
it('with strictMode:true, attach resolves but subscribe rejects with 90009 and a subscribe-mode hint', async function () {
21222122
const helper = this.test.helper;
21232123
const realtime = helper.AblyRealtime({ strictMode: true });
21242124
await helper.monitorConnectionThenCloseAndFinishAsync(async () => {
@@ -2132,7 +2132,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, Helper, async
21322132
caught = err;
21332133
}
21342134
expect(caught, 'expected channel.subscribe() to reject').to.exist;
2135-
expect(caught.code).to.equal(93003);
2135+
expect(caught.code).to.equal(90009);
21362136
expect(caught.hint).to.be.a('string');
21372137
expect(caught.hint).to.contain('subscribe');
21382138
expect(caught.hint).to.contain('ably auth keys list');

test/realtime/presence.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,7 +2501,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, Helper, async
25012501
});
25022502

25032503
describe('presence.get() without presence_subscribe mode', function () {
2504-
it('with strictMode:true, rejects with 93002 and hint naming presence_subscribe', function (done) {
2504+
it('with strictMode:true, rejects with 91008 and hint naming presence_subscribe', function (done) {
25052505
const helper = this.test.helper;
25062506
const channelName = 'presence-get-without-mode-strict-' + String(Math.random()).slice(2);
25072507
let realtime;
@@ -2517,7 +2517,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, Helper, async
25172517
Helper.whenPromiseSettles(channel.presence.get(), function (err) {
25182518
try {
25192519
expect(err, 'expected presence.get() to reject').to.exist;
2520-
expect(err.code).to.equal(93002);
2520+
expect(err.code).to.equal(91008);
25212521
expect(err.hint).to.be.a('string');
25222522
expect(err.hint).to.contain('presence_subscribe');
25232523
expect(err.hint).to.contain('ably auth keys list');

0 commit comments

Comments
 (0)