Skip to content

Commit ca683b5

Browse files
chrisbobbegnprice
authored andcommitted
api: Log to Sentry when refusing to connect to an ancient server
And, since we'll be logging `ServerTooOldError`s to Sentry, change the error message to use `.coarse` instead of `.raw`, since at least when the version has a Git commit ID in it, we expect `.raw` would cause the logs to get split up into a bunch of different issues for different commit IDs.
1 parent 0755db1 commit ca683b5

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/api/apiErrors.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,17 @@ export const kMinAllowedServerVersion: ZulipVersion = new ZulipVersion('2.0');
183183

184184
/**
185185
* An error we throw in API bindings on finding a server is too old.
186+
*
187+
* Handling code should:
188+
* - refuse to interact with the server except to check if it's been updated
189+
* - log out the user
190+
* - log to Sentry (so we have a sense of how often this happens)
186191
*/
187192
export class ServerTooOldError extends ExtendableError {
188193
version: ZulipVersion;
189194

190195
constructor(version: ZulipVersion) {
191-
super(`Unsupported Zulip Server version: ${version.raw()}`);
196+
super(`Unsupported Zulip Server version: ${version.classify().coarse}`);
192197
this.version = version;
193198
}
194199
}

src/events/eventActions.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
Server5xxError,
2727
NetworkError,
2828
ServerTooOldError,
29+
kMinAllowedServerVersion,
2930
} from '../api/apiErrors';
3031
import * as logging from '../utils/logging';
3132
import { showErrorAlert } from '../utils/info';
@@ -178,6 +179,12 @@ export const registerAndStartPolling =
178179
globalSettings: getGlobalSettings(),
179180
},
180181
);
182+
logging.setTagsFromServerVersion(e.version);
183+
logging.error(e, {
184+
kMinAllowedServerVersion: kMinAllowedServerVersion.raw(),
185+
kMinSupportedVersion: kMinSupportedVersion.raw(),
186+
kNextMinSupportedVersion: kNextMinSupportedVersion.raw(),
187+
});
181188
// Don't delay the logout action by awaiting this request: it may
182189
// take a long time or never succeed, and we need to kick the user
183190
// out immediately.

src/message/fetchActions.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
ApiError,
1919
MalformedResponseError,
2020
ServerTooOldError,
21+
kMinAllowedServerVersion,
2122
} from '../api/apiErrors';
2223
import {
2324
getAuth,
@@ -41,7 +42,7 @@ import { ALL_PRIVATE_NARROW, apiNarrowOfNarrow, caseNarrow, topicNarrow } from '
4142
import { BackoffMachine, promiseTimeout, TimeoutError } from '../utils/async';
4243
import { getAllUsersById, getOwnUserId } from '../users/userSelectors';
4344
import type { ServerSettings } from '../api/settings/getServerSettings';
44-
import { kMinSupportedVersion } from '../common/ServerCompatBanner';
45+
import { kMinSupportedVersion, kNextMinSupportedVersion } from '../common/ServerCompatBanner';
4546

4647
const messageFetchStart = (
4748
narrow: Narrow,
@@ -444,6 +445,12 @@ export async function fetchServerSettings(realm: URL): Promise<
444445
'https://zulip.readthedocs.io/en/stable/overview/release-lifecycle.html#compatibility-and-upgrading',
445446
),
446447
};
448+
logging.setTagsFromServerVersion(error.version);
449+
logging.error(error, {
450+
kMinAllowedServerVersion: kMinAllowedServerVersion.raw(),
451+
kMinSupportedVersion: kMinSupportedVersion.raw(),
452+
kNextMinSupportedVersion: kNextMinSupportedVersion.raw(),
453+
});
447454
} else if (error instanceof MalformedResponseError && error.httpStatus === 404) {
448455
message = {
449456
text: 'The server at {realm} does not seem to be a Zulip server.',

0 commit comments

Comments
 (0)