- callLoginMethod is an async function now

- handle async hooks inside _callOnReconnectAndSendAppropriateOutstandingMethods
This commit is contained in:
denihs
2024-07-09 12:25:43 -04:00
parent c2bf9bfc55
commit 82fc4e7aa4
2 changed files with 7 additions and 8 deletions

View File

@@ -307,7 +307,7 @@ export class AccountsClient extends AccountsCommon {
if (this._tokenExpiresSoon(result.tokenExpires)) {
this.makeClientLoggedOut();
} else {
this.callLoginMethod({
return this.callLoginMethod({
methodArguments: [{resume: result.token}],
// Reconnect quiescence ensures that the user doesn't see an
// intermediate state before the login method finishes. So we don't
@@ -396,7 +396,7 @@ export class AccountsClient extends AccountsCommon {
if (!options._suppressLoggingIn) {
this._setLoggingIn(true);
}
this.connection.apply(
return this.connection.applyAsync(
options.methodName,
options.methodArguments,
{ wait: true, onResultReceived: onResultReceived },

View File

@@ -1789,15 +1789,14 @@ export class Connection {
if (msg.offendingMessage) Meteor._debug('For: ', msg.offendingMessage);
}
_callOnReconnectAndSendAppropriateOutstandingMethods() {
async _callOnReconnectAndSendAppropriateOutstandingMethods() {
const self = this;
const oldOutstandingMethodBlocks = self._outstandingMethodBlocks;
self._outstandingMethodBlocks = [];
self.onReconnect && self.onReconnect();
DDP._reconnectHook.each(callback => {
callback(self);
return true;
await DDP._reconnectHook.forEachAsync(async callback => {
await callback(self);
});
if (isEmpty(oldOutstandingMethodBlocks)) return;
@@ -1904,7 +1903,7 @@ export class Connection {
}
}
onReset() {
async onReset() {
// Send a connect message at the beginning of the stream.
// NOTE: reset is called even on the first connection, so this is
// the only place we send this message.
@@ -1977,7 +1976,7 @@ export class Connection {
// `onReconnect` get executed _before_ ones that were originally
// outstanding (since `onReconnect` is used to re-establish auth
// certificates)
this._callOnReconnectAndSendAppropriateOutstandingMethods();
await this._callOnReconnectAndSendAppropriateOutstandingMethods();
// add new subscriptions at the end. this way they take effect after
// the handlers and we don't see flicker.