Skip to content

Commit 836a95e

Browse files
committed
Warn about usage of very outdated server/desktop versions
We're no longer testing anything against these old versions, and there's lots of major features they won't support. They will _probably_ work, but the risk of issues is high, and it's been many years since they were released (desktop v1.1.0 was January 2021) so it would be good to gently nudge any people still using them to update.
1 parent 624b5fb commit 836a95e

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "httptoolkit-ui",
3-
"version": "0.1.0",
43
"private": true,
54
"description": "Beautiful, cross-platform & open-source HTTP(S) debugging proxy, analyzer & client.",
65
"main": "dist/main.js",
@@ -35,7 +34,8 @@
3534
"author": "Tim Perry <[email protected]>",
3635
"license": "AGPL-3.0-or-later",
3736
"runtimeDependencies": {
38-
"httptoolkit-server": "^0.1.18 || ^1.0.0"
37+
"httptoolkit-server": ">=1.0.0",
38+
"httptoolkit-desktop": ">=1.1.0"
3939
},
4040
"dependencies": {
4141
"@ethersproject/abi": "^5.7.0",

src/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { SendStore } from './model/send/send-store';
3535
import { serverVersion, lastServerVersion, UI_VERSION } from './services/service-versions';
3636
import {
3737
attemptServerUpdate,
38+
checkForOutdatedComponents,
3839
runBackgroundUpdates
3940
} from './services/update-management';
4041

@@ -52,6 +53,7 @@ mobx.configure({ enforceActions: 'observed' });
5253
// background updates & instant offline startup. We slightly delay this to avoid
5354
// competing for bandwidth/CPU/etc with startup on slow connections.
5455
delay(5000).then(runBackgroundUpdates);
56+
checkForOutdatedComponents();
5557

5658
const accountStore = new AccountStore(
5759
() => appHistory.navigate('/settings')

src/services/service-versions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ export const serverVersion = lazyObservablePromise(() =>
2424
})
2525
);
2626

27-
// Notable desktop versions:
28-
export const DESKTOP_HEADER_LIMIT_CONFIGURABLE = "^0.1.20 || ^1.0.0";
29-
3027
// The last known service version - immediately available (though still async),
3128
// but reports the previous startup version, not necessarily the latest one.
3229
// May be undefined if the app has never yet started successfully.
@@ -45,6 +42,9 @@ export function versionSatisfies(version: string | Error | undefined, range: str
4542
semver.satisfies(version, range, { includePrerelease: true });
4643
}
4744

45+
// Notable desktop versions:
46+
export const DESKTOP_HEADER_LIMIT_CONFIGURABLE = "^0.1.20 || ^1.0.0";
47+
4848
// Notable server versions:
4949
export const PORT_RANGE_SERVER_RANGE = '^0.1.14 || ^1.0.0';
5050
export const MOCK_SERVER_RANGE = '^0.1.21 || ^1.0.0';

src/services/ui-update-worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PrecacheController } from 'workbox-precaching'
88
import { ExpirationPlugin } from 'workbox-expiration';
99
import { StaleWhileRevalidate, NetworkOnly } from 'workbox-strategies';
1010

11-
import * as packageMetadata from '../../package.json';
11+
import packageMetadata from '../../package.json';
1212
import { getServerVersion } from './server-api';
1313
import { lastServerVersion, versionSatisfies } from './service-versions';
1414
import { delay } from '../util/promise';

src/services/update-management.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import dedent from 'dedent';
2+
13
import registerUpdateWorker, {
24
ServiceWorkerNoSupportError
35
} from 'service-worker-loader!./ui-update-worker';
46

57
import { triggerServerUpdate } from './server-api';
68

9+
import packageMetadata from '../../package.json';
10+
import { desktopVersion, serverVersion, versionSatisfies } from './service-versions';
11+
712
export const attemptServerUpdate = () =>
813
triggerServerUpdate().catch(console.warn);
914

@@ -31,4 +36,45 @@ export async function runBackgroundUpdates() {
3136
}
3237
throw e;
3338
}
39+
}
40+
41+
function showPleaseUpdateMessage() {
42+
alert(
43+
"This HTTP Toolkit installation is now very outdated, and this version is " +
44+
"no longer supported." +
45+
"\n\n" +
46+
"You can continue to use HTTP Toolkit, but you may experience issues & " +
47+
"instability." +
48+
"\n\n" +
49+
"Please update to the latest version from httptoolkit.com when you can, " +
50+
"to access the many new features, bug fixes & performance improvements " +
51+
"available there."
52+
);
53+
}
54+
55+
export function checkForOutdatedComponents() {
56+
const { runtimeDependencies } = packageMetadata;
57+
58+
let hasShownUpdateMessage = false;
59+
60+
serverVersion.then((serverVersion) => {
61+
if (versionSatisfies(serverVersion, runtimeDependencies['httptoolkit-server'])) return;
62+
if (hasShownUpdateMessage) return;
63+
64+
// This one should be _very_ rare, since the server always auto-updates - it'll only
65+
// affect systems where that is failing for some reason, for years.
66+
67+
showPleaseUpdateMessage();
68+
hasShownUpdateMessage = true;
69+
}).catch(() => {});
70+
71+
desktopVersion.then((desktopVersion) => {
72+
if (versionSatisfies(desktopVersion, runtimeDependencies['httptoolkit-desktop'])) return;
73+
if (hasShownUpdateMessage) return;
74+
75+
// This will trigger for a few users, but not many - below 0.2% of weekly users right now
76+
77+
showPleaseUpdateMessage();
78+
hasShownUpdateMessage = true;
79+
}).catch(() => {});
3480
}

0 commit comments

Comments
 (0)