Skip to content

Commit 78a4bf9

Browse files
committed
feat(sdk): route all DDP method traffic (login resume, logout, setUserStatus) through DDPSDK
Trim the remaining ddpOverSDK bypass list to only the structural cases: - msg !== 'method' (subs etc. still native) - method starts with 'stream-' (stream-prefixed RPCs — sdk.publish already handles these directly when DDPSDK is ready) Everything else now flows through our SDK's WebSocket: - setUserStatus: plain mutation, no per-connection state - logout: the result still propagates back to Meteor's invoker machinery via our processResult(), so Accounts.onLogout / userId cleanup run as before. No more bypass needed. - login with {resume}: the Meteor.loginWithToken dance that re-queues a resume login after non-resume logins is guarded with wasResumeLogin so it doesn't recurse when the response we're processing *is* a resume. Net effect: the only DDP messages that still ride Meteor's WS are non-method frames (subscribes, heartbeats) and the rare stream-* RPC.
1 parent 1c449f8 commit 78a4bf9

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

apps/meteor/client/meteor/overrides/ddpOverREST.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,15 @@ import { sdk } from '../../../app/utils/client/lib/SDKClient';
55
import { getDdpSdk } from '../../lib/sdk/ddpSdk';
66
import { getUserId } from '../../lib/user';
77

8-
const bypassMethods: string[] = ['setUserStatus', 'logout'];
8+
const bypassMethods: string[] = [];
99

10-
const shouldBypass = ({ msg, method, params }: Meteor.IDDPMessage): boolean => {
11-
if (msg !== 'method') {
12-
return true;
13-
}
10+
const isResumeLogin = ({ method, params }: Meteor.IDDPMessage): boolean => method === 'login' && Boolean(params?.[0]?.resume);
1411

15-
if (method === 'login' && params[0]?.resume) {
12+
const shouldBypass = ({ msg, method }: Meteor.IDDPMessage): boolean => {
13+
if (msg !== 'method') {
1614
return true;
1715
}
1816

19-
// `logout` mutates per-connection auth state on Meteor's side; keeping it on
20-
// Meteor.connection ensures the subsequent Accounts.onLogout chain (userId
21-
// cleanup, ServerContext status flip, etc.) fires as before.
22-
// `setUserStatus` toggles `_updatedAt` and presence fields that the Meteor
23-
// user stream is still expected to drive while it remains the auth anchor.
2417
if (bypassMethods.includes(method)) {
2518
return true;
2619
}
@@ -60,14 +53,16 @@ const withDDPOverSDK = (_send: (this: Meteor.IMeteorConnection, message: Meteor.
6053
// Meteor's own WS.
6154
if (isDdpSdkReady()) {
6255
const params = Array.isArray(message.params) ? message.params : [];
56+
const wasResumeLogin = isResumeLogin(message);
6357
getDdpSdk()
6458
.client.callAsync(message.method, ...params)
6559
.then((result: unknown) => {
6660
// Keep the Meteor.loginWithToken dance the REST version did so the
6761
// Accounts state (userId, token, onLogin callbacks) updates the same
68-
// way post-login. See the previous ddp-over-REST implementation for
69-
// the detailed ordering of onLogin / loginWithToken interplay.
62+
// way post-login. Skip it on resume-login responses — the dance
63+
// itself calls Meteor.loginWithToken again and would recurse.
7064
if (
65+
!wasResumeLogin &&
7166
message.method === 'login' &&
7267
typeof result === 'object' &&
7368
result !== null &&

0 commit comments

Comments
 (0)