diff options
| author | Sambhav Khanna <[email protected]> | 2025-07-29 20:11:15 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-30 00:11:15 +0000 |
| commit | d5a1b717c258b3913dc41800f5a976ed9d60792a (patch) | |
| tree | ad5d02a4883a176c5a7a738076797f09e25348e2 /packages/cli/src/ui/utils/updateCheck.ts | |
| parent | 091804c7507be25d8063a236210de0c31671783b (diff) | |
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 <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/utils/updateCheck.ts')
| -rw-r--r-- | packages/cli/src/ui/utils/updateCheck.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/cli/src/ui/utils/updateCheck.ts b/packages/cli/src/ui/utils/updateCheck.ts index b0a0de1b..2fe5df39 100644 --- a/packages/cli/src/ui/utils/updateCheck.ts +++ b/packages/cli/src/ui/utils/updateCheck.ts @@ -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 { |
