mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
fix(update): correctly report new updates (#4821)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -8,6 +8,8 @@ import updateNotifier, { UpdateInfo } from 'update-notifier';
|
||||
import semver from 'semver';
|
||||
import { getPackageJson } from '../../utils/package.js';
|
||||
|
||||
export const FETCH_TIMEOUT_MS = 2000;
|
||||
|
||||
export interface UpdateObject {
|
||||
message: string;
|
||||
update: UpdateInfo;
|
||||
@@ -34,8 +36,11 @@ export async function checkForUpdates(): Promise<UpdateObject | null> {
|
||||
// allow notifier to run in scripts
|
||||
shouldNotifyInNpmScript: true,
|
||||
});
|
||||
|
||||
const updateInfo = await notifier.fetchInfo();
|
||||
// avoid blocking by waiting at most FETCH_TIMEOUT_MS for fetchInfo to resolve
|
||||
const timeout = new Promise<null>((resolve) =>
|
||||
setTimeout(resolve, FETCH_TIMEOUT_MS, null),
|
||||
);
|
||||
const updateInfo = await Promise.race([notifier.fetchInfo(), timeout]);
|
||||
|
||||
if (updateInfo && semver.gt(updateInfo.latest, updateInfo.current)) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user