Spaces:
Paused
Paused
icebear0828 Claude Opus 4.6 commited on
Commit ·
2fac785
1
Parent(s): f9a006a
fix: semver comparison + timer cleanup in self-update
Browse files- Use localeCompare with numeric option instead of string equality for
version comparison (prevents false "update available" on rollbacks)
- Add .unref() to setTimeout/setInterval to not block process exit
- Add void to fire-and-forget runCheck() calls
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- src/self-update.ts +7 -3
src/self-update.ts
CHANGED
|
@@ -216,7 +216,9 @@ export async function checkProxySelfUpdate(): Promise<ProxySelfUpdateResult> {
|
|
| 216 |
// Docker or Electron — GitHub Releases API
|
| 217 |
const release = await checkGitHubRelease();
|
| 218 |
const currentVersion = getProxyInfo().version;
|
| 219 |
-
const updateAvailable = release !== null
|
|
|
|
|
|
|
| 220 |
|
| 221 |
const result: ProxySelfUpdateResult = {
|
| 222 |
commitsBehind: 0, currentCommit: null, latestCommit: null,
|
|
@@ -276,12 +278,14 @@ async function runCheck(): Promise<void> {
|
|
| 276 |
/** Start periodic proxy update checking (initial check after 10s, then every 6h). */
|
| 277 |
export function startProxyUpdateChecker(): void {
|
| 278 |
_initialTimer = setTimeout(() => {
|
| 279 |
-
runCheck();
|
| 280 |
}, INITIAL_DELAY_MS);
|
|
|
|
| 281 |
|
| 282 |
_checkTimer = setInterval(() => {
|
| 283 |
-
runCheck();
|
| 284 |
}, CHECK_INTERVAL_MS);
|
|
|
|
| 285 |
}
|
| 286 |
|
| 287 |
/** Stop periodic proxy update checking. */
|
|
|
|
| 216 |
// Docker or Electron — GitHub Releases API
|
| 217 |
const release = await checkGitHubRelease();
|
| 218 |
const currentVersion = getProxyInfo().version;
|
| 219 |
+
const updateAvailable = release !== null
|
| 220 |
+
&& release.version !== currentVersion
|
| 221 |
+
&& release.version.localeCompare(currentVersion, undefined, { numeric: true }) > 0;
|
| 222 |
|
| 223 |
const result: ProxySelfUpdateResult = {
|
| 224 |
commitsBehind: 0, currentCommit: null, latestCommit: null,
|
|
|
|
| 278 |
/** Start periodic proxy update checking (initial check after 10s, then every 6h). */
|
| 279 |
export function startProxyUpdateChecker(): void {
|
| 280 |
_initialTimer = setTimeout(() => {
|
| 281 |
+
void runCheck();
|
| 282 |
}, INITIAL_DELAY_MS);
|
| 283 |
+
_initialTimer.unref();
|
| 284 |
|
| 285 |
_checkTimer = setInterval(() => {
|
| 286 |
+
void runCheck();
|
| 287 |
}, CHECK_INTERVAL_MS);
|
| 288 |
+
_checkTimer.unref();
|
| 289 |
}
|
| 290 |
|
| 291 |
/** Stop periodic proxy update checking. */
|