Skip to content

fix: handle unhandled promise rejections in auto-updater#3296

Open
jeanfbrito wants to merge 1 commit intodevfrom
fix/unhandled-update-check-rejection
Open

fix: handle unhandled promise rejections in auto-updater#3296
jeanfbrito wants to merge 1 commit intodevfrom
fix/unhandled-update-check-rejection

Conversation

@jeanfbrito
Copy link
Copy Markdown
Member

@jeanfbrito jeanfbrito commented Apr 9, 2026

Summary

  • Fix unhandled promise rejection (ERR_UPDATER_NO_PUBLISHED_VERSIONS) that crashes the app when the GitHub releases feed is unreachable for some users
  • Properly await the checkForUpdates() promise in user-initiated checks — it was previously fire-and-forget inside a setTimeout callback, escaping the try-catch
  • Properly await the downloadUpdate() promise so its try-catch also works

Context

Some users report an unhandled promise rejection when checking for updates. The same version works for others — the releases exist on GitHub, but the affected machines can't reach the Atom feed (likely network/proxy/rate-limiting). The startup check (await autoUpdater.checkForUpdates()) handled this correctly, but the user-initiated check and download path did not.

Test plan

  • npx tsc --noEmit passes
  • yarn lint passes
  • yarn test — 213/213 tests pass
  • Manual: verify no crash when GitHub releases are unreachable
  • Manual: verify normal update flow still works

Summary by CodeRabbit

Bug Fixes

  • Improved update system reliability by ensuring update checks and downloads are properly synchronized with enhanced error handling to report issues to users more effectively.

The user-initiated update check wrapped checkForUpdates() inside
setTimeout without awaiting the returned promise, causing unhandled
rejections when the GitHub releases feed is unreachable. Similarly,
downloadUpdate() was not awaited. Both now properly await their
promises so the existing try-catch blocks can catch errors.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d77a1eac-3010-4e57-a73d-332cd5ea16ac

📥 Commits

Reviewing files that changed from the base of the PR and between 7f961f4 and 83a6c02.

📒 Files selected for processing (1)
  • src/updates/main.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: check (ubuntu-latest)
  • GitHub Check: check (windows-latest)
  • GitHub Check: check (macos-latest)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Use TypeScript for all new code in this codebase unless explicitly told otherwise
Use Fuselage components from @rocket.chat/fuselage for all UI work — only create custom components when Fuselage doesn't provide the needed functionality
Check Theme.d.ts for valid color tokens when working with Fuselage components
Use optional chaining with fallbacks for platform-specific APIs instead of mocks (e.g., process.getuid?.() ?? 1000) to ensure code works across all platforms without requiring mocks
TypeScript code must use strict mode
Use React functional components with hooks instead of class components
Redux actions must follow the FSA (Flux Standard Action) pattern
Use camelCase for file naming
Use PascalCase for component file names (React components)
Write self-documenting code through clear naming — avoid unnecessary comments

Files:

  • src/updates/main.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: Ram-sah19
Repo: RocketChat/Rocket.Chat.Electron PR: 3254
File: .github/workflows/build-release.yml:80-94
Timestamp: 2026-03-11T06:38:40.426Z
Learning: In the RocketChat/Rocket.Chat.Electron repository, the issues flagged in `.github/workflows/build-release.yml` (e.g., `node12` runtime in the release action and missing `snapcraft_token` input), i18n files, and `electron-builder.json` are pre-existing in the `develop` branch and are pulled in during merge conflict resolution. Do not flag these as new issues introduced by PRs that only modify `src/injected.ts` and `src/ui/main/rootWindow.ts`.
🔇 Additional comments (2)
src/updates/main.ts (2)

352-353: Good fix for user-initiated update checks.

Awaiting both steps keeps rejections from checkForUpdates() inside the existing try/catch (Line 352, Line 353), which addresses the unhandled rejection path cleanly.


379-379: Nice catch on awaiting the download path.

await autoUpdater.downloadUpdate() (Line 379) correctly routes promise rejections through the current try/catch instead of leaking as unhandled rejections.


Walkthrough

This change modifies the update initialization and download flows in src/updates/main.ts to properly await async operations, ensuring errors propagate through existing error handling instead of being silently dropped.

Changes

Cohort / File(s) Summary
Update Error Handling
src/updates/main.ts
Modified setupUpdates to await setTimeout before initiating update checks, and changed autoUpdater.checkForUpdates() and autoUpdater.downloadUpdate() from fire-and-forget calls to proper awaits so download errors propagate through the try/catch block.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main purpose of the PR: fixing unhandled promise rejections in auto-updater code by ensuring promises are properly awaited.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant