From 8cf579117bd0210ceee1102739ab1338999673c6 Mon Sep 17 00:00:00 2001 From: SimonLaux Date: Sat, 11 Jan 2025 05:07:32 +0100 Subject: [PATCH] add special error dialog for the case that deltachat-rpc-server is not found closes #4469 --- CHANGELOG.md | 5 +++ .../src/deltachat/controller.ts | 2 +- .../src/deltachat/stdio_server.ts | 41 ++++++++++++++++++- packages/target-electron/src/ipc.ts | 10 +++-- 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7c707ad85..67a0405881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,8 +49,13 @@ - accessibility: arrow-key navigation for message list, gallery and sticker picker #4294, #4376, #4372, - accessibility: arrow-key navigation: handle "End" and "Home" keys to go to last / first item #4438 - add show_app_in_chat option to webxdc info message context menu #4459 +<<<<<<< HEAD - add experimental content protection option (to prevent screenshots and screenrecording the app) #4475 - app picker for webxdc apps in attachement menu #4485 +- add special error dialog for the case that deltachat-rpc-server is not found +======= +- add special error dialog for the case that deltachat-rpc-server is not found #4479 +>>>>>>> cf5337ce0 (add pr number to changelog) ### Changed - Update `@deltachat/stdio-rpc-server` and `deltachat/jsonrpc-client` to `1.154.1` diff --git a/packages/target-electron/src/deltachat/controller.ts b/packages/target-electron/src/deltachat/controller.ts index 81ab81d624..c2a6693592 100644 --- a/packages/target-electron/src/deltachat/controller.ts +++ b/packages/target-electron/src/deltachat/controller.ts @@ -141,7 +141,7 @@ export default class DeltaChatController extends EventEmitter { serverPath ) - await this.account_manager.start() + this.account_manager.start() log.info('HI') //todo? multiple instances, accounts is always writable diff --git a/packages/target-electron/src/deltachat/stdio_server.ts b/packages/target-electron/src/deltachat/stdio_server.ts index 1968cabd2f..95193ecb3c 100644 --- a/packages/target-electron/src/deltachat/stdio_server.ts +++ b/packages/target-electron/src/deltachat/stdio_server.ts @@ -3,6 +3,7 @@ import { ChildProcessWithoutNullStreams, spawn } from 'child_process' import { app, dialog } from 'electron/main' import { BuildInfo } from '../get-build-info' import { arch, platform } from 'os' +import { getLogsPath } from '../application-constants' const log = getLogger('DC-RPC') @@ -16,7 +17,7 @@ export class StdioServer { this.serverProcess = null } - async start() { + start() { this.serverProcess = spawn(this.cmd_path, { env: { DC_ACCOUNTS_PATH: this.accounts_path, @@ -24,6 +25,44 @@ export class StdioServer { }, }) + this.serverProcess.on('error', err => { + // The 'error' event is emitted whenever: + // - The process could not be spawned. + // - The process could not be killed. + // - Sending a message to the child process failed. + // - The child process was aborted via the signal option. + // ~ https://nodejs.org/api/child_process.html#event-error + + if (err.message.endsWith('ENOENT')) { + dialog.showErrorBox( + 'Fatal Error: Core Library Missing', + `The DeltaChat Module is missing! It should be located at "${ + this.cmd_path + }". + +This could be due to your antivirus program. Please check the quarantine to restore it and notify the developer about this issue. +You can reach us on delta@merlinux.eu or on github.com/deltachat/deltachat-desktop/issues . + +The Log file is located in this folder: ${getLogsPath()} +-------------------- +Error: ${err.message} +` + ) + } else { + dialog.showErrorBox( + 'Fatal Error', + `Error with core has been detected, please contact developers: You can reach us on delta@merlinux.eu or on github.com/deltachat/deltachat-desktop/issues . + + ${err.name}: ${err.message} + + The Log file is located in this folder: ${getLogsPath()}\n + ` + ) + } + // I think we can exit in all the cases, because all errors here are serious + app.exit(1) + }) + let buffer = '' this.serverProcess.stdout.on('data', data => { // console.log(`stdout: ${data}`) diff --git a/packages/target-electron/src/ipc.ts b/packages/target-electron/src/ipc.ts index 6d9315a9b6..4389bb828d 100644 --- a/packages/target-electron/src/ipc.ts +++ b/packages/target-electron/src/ipc.ts @@ -65,14 +65,16 @@ export async function init(cwd: string, logHandler: LogHandler) { error, dcController.rpcServerPath ) + dialog.showErrorBox( 'Fatal Error', `The DeltaChat Module couldn't be loaded. -Please check if all dependencies for deltachat-core are installed! -The Log file is located in this folder: ${getLogsPath()}\n -${dcController.rpcServerPath}\n -${error instanceof Error ? error.message : inspect(error, { depth: null })}` + Please check if all dependencies for deltachat-core are installed! + The Log file is located in this folder: ${getLogsPath()}\n + ${dcController.rpcServerPath}\n + ${error instanceof Error ? error.message : inspect(error, { depth: null })}` ) + rawApp.exit(1) }