Skip to content

Commit e7923d0

Browse files
authored
fix(electron): improve error handling during app initialization and updater events (#461)
1 parent abc0c6e commit e7923d0

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

electron/main/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ app.on('second-instance', () => {
365365

366366
// Application lifecycle
367367
app.whenReady().then(() => {
368-
initialize();
368+
void initialize().catch((error) => {
369+
logger.error('Application initialization failed:', error);
370+
});
369371

370372
// Register activate handler AFTER app is ready to prevent
371373
// "Cannot create BrowserWindow before app is ready" on macOS.

electron/main/updater.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export class AppUpdater extends EventEmitter {
5252

5353
constructor() {
5454
super();
55+
56+
// EventEmitter treats an unhandled 'error' event as fatal. Keep a default
57+
// listener so updater failures surface in logs/UI without terminating main.
58+
this.on('error', (error: Error) => {
59+
logger.error('[Updater] AppUpdater emitted error:', error);
60+
});
5561

5662
autoUpdater.autoDownload = false;
5763
autoUpdater.autoInstallOnAppQuit = true;

src/components/channels/ChannelConfigModal.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export function ChannelConfigModal({
8585
} | null>(null);
8686

8787
const meta: ChannelMeta | null = selectedType ? CHANNEL_META[selectedType] : null;
88+
const shouldUseCredentialValidation = selectedType !== 'feishu';
8889

8990
useEffect(() => {
9091
setSelectedType(initialSelectedType);
@@ -224,7 +225,7 @@ export function ChannelConfigModal({
224225
}, [selectedType, finishSave, onClose, t]);
225226

226227
const handleValidate = async () => {
227-
if (!selectedType) return;
228+
if (!selectedType || !shouldUseCredentialValidation) return;
228229

229230
setValidating(true);
230231
setValidationResult(null);
@@ -280,7 +281,7 @@ export function ChannelConfigModal({
280281
return;
281282
}
282283

283-
if (meta.connectionType === 'token') {
284+
if (meta.connectionType === 'token' && shouldUseCredentialValidation) {
284285
const validationResponse = await hostApiFetch<{
285286
success: boolean;
286287
valid?: boolean;
@@ -598,7 +599,7 @@ export function ChannelConfigModal({
598599

599600
<div className="flex flex-col sm:flex-row sm:justify-end gap-3 pt-2">
600601
<div className="flex flex-col sm:flex-row gap-2">
601-
{meta?.connectionType === 'token' && (
602+
{meta?.connectionType === 'token' && shouldUseCredentialValidation && (
602603
<Button
603604
variant="outline"
604605
onClick={handleValidate}

0 commit comments

Comments
 (0)