[PR #2190] [MERGED] ♻️ refactor(electron): moving back from websockets to IPC #45989

Closed
opened 2026-04-26 08:05:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/2190
Author: @MatissJanis
Created: 1/7/2024
Status: Merged
Merged: 1/8/2024
Merged by: @MatissJanis

Base: masterHead: matiss/electron-app-ipc


📝 Commits (2)

  • c8551d5 ♻️ refactor(electron): moving back from websockets to IPC
  • 51766e8 Release notes

📊 Changes

14 files changed (+187 additions, -331 deletions)

View changed files

📝 .gitattributes (+1 -1)
📝 packages/desktop-client/src/browser-preload.browser.js (+1 -0)
📝 packages/desktop-electron/index.js (+21 -63)
📝 packages/desktop-electron/package.json (+1 -3)
📝 packages/desktop-electron/preload.js (+12 -10)
📝 packages/desktop-electron/server.js (+3 -18)
📝 packages/loot-core/package.json (+1 -3)
📝 packages/loot-core/src/client/actions/app.ts (+1 -7)
📝 packages/loot-core/src/platform/client/fetch/index.web.ts (+66 -84)
📝 packages/loot-core/src/platform/server/connection/index.electron.ts (+58 -95)
📝 packages/loot-core/src/server/main.ts (+5 -2)
📝 packages/loot-core/webpack/webpack.desktop.config.js (+1 -8)
upcoming-release-notes/2190.md (+6 -0)
📝 yarn.lock (+10 -37)

📄 Description

Partial revert of https://github.com/actualbudget/actual/pull/1003

--

The original PR #1003 was solving a problem in electron: we cannot use node server modules in client or server subprocesses (where we run all the API handlers). It moved the communication from one that centers around node-ipc as the central communication hub to websockets.

node-ipc:

flowchart TD
    client --> node-ipc
    node-ipc --> server
    node-ipc --> server-subprocess
    node-ipc --> client
    server --> node-ipc
    server-subprocess --> node-ipc

websockets:

flowchart TD
    client --> websockets
    websockets --> server
    websockets --> server-subprocess
    websockets --> client
    server --> websockets
    server-subprocess --> websockets

This worked fine.. for the most part. But when it did not work - it failed spectacularly. This was mostly due to websockets not being able to find an open socket and thus just not working. Or when it randomly crashed mid-session..

The solution I am proposing here is to move back to the communication protocol recommended by electron: IPC. This is how the communication looks now:

flowchart TD
    client --> server
    server --> server-subprocess
    server-subprocess --> server
    server --> client

This solution creates a much more stable electron environment during my manual tests while solving the original problem: removal of node server dependencies from client and subprocess.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/2190 **Author:** [@MatissJanis](https://github.com/MatissJanis) **Created:** 1/7/2024 **Status:** ✅ Merged **Merged:** 1/8/2024 **Merged by:** [@MatissJanis](https://github.com/MatissJanis) **Base:** `master` ← **Head:** `matiss/electron-app-ipc` --- ### 📝 Commits (2) - [`c8551d5`](https://github.com/actualbudget/actual/commit/c8551d517b7d1182e3864934c8a6456b0b762ebb) :recycle: refactor(electron): moving back from websockets to IPC - [`51766e8`](https://github.com/actualbudget/actual/commit/51766e878214900814f0cbf13df174806c7151b3) Release notes ### 📊 Changes **14 files changed** (+187 additions, -331 deletions) <details> <summary>View changed files</summary> 📝 `.gitattributes` (+1 -1) 📝 `packages/desktop-client/src/browser-preload.browser.js` (+1 -0) 📝 `packages/desktop-electron/index.js` (+21 -63) 📝 `packages/desktop-electron/package.json` (+1 -3) 📝 `packages/desktop-electron/preload.js` (+12 -10) 📝 `packages/desktop-electron/server.js` (+3 -18) 📝 `packages/loot-core/package.json` (+1 -3) 📝 `packages/loot-core/src/client/actions/app.ts` (+1 -7) 📝 `packages/loot-core/src/platform/client/fetch/index.web.ts` (+66 -84) 📝 `packages/loot-core/src/platform/server/connection/index.electron.ts` (+58 -95) 📝 `packages/loot-core/src/server/main.ts` (+5 -2) 📝 `packages/loot-core/webpack/webpack.desktop.config.js` (+1 -8) ➕ `upcoming-release-notes/2190.md` (+6 -0) 📝 `yarn.lock` (+10 -37) </details> ### 📄 Description Partial revert of https://github.com/actualbudget/actual/pull/1003 -- The original PR #1003 was solving a problem in electron: we cannot use `node` server modules in `client` or server subprocesses (where we run all the API handlers). It moved the communication from one that centers around `node-ipc` as the central communication hub to `websockets`. node-ipc: ```mermaid flowchart TD client --> node-ipc node-ipc --> server node-ipc --> server-subprocess node-ipc --> client server --> node-ipc server-subprocess --> node-ipc ``` websockets: ```mermaid flowchart TD client --> websockets websockets --> server websockets --> server-subprocess websockets --> client server --> websockets server-subprocess --> websockets ``` This worked fine.. for the most part. But when it did not work - it failed spectacularly. This was mostly due to websockets not being able to find an open socket and thus just not working. Or when it randomly crashed mid-session.. The solution I am proposing here is to move back to the communication protocol recommended by electron: [IPC](https://www.electronjs.org/docs/latest/tutorial/ipc). This is how the communication looks now: ```mermaid flowchart TD client --> server server --> server-subprocess server-subprocess --> server server --> client ``` This solution creates a much more stable electron environment during my manual tests while solving the original problem: removal of `node` server dependencies from client and subprocess. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-26 08:05:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#45989