[PR #3631] [CLOSED] [WIP] :electron: hosting the sync-server with the desktop app (POC) #4968

Closed
opened 2026-02-28 21:03:58 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/3631
Author: @MikesGlitch
Created: 10/10/2024
Status: Closed

Base: masterHead: electron/server-hosting


📝 Commits (10+)

  • 20e2ef2 start to this epic idea
  • 361200e bits
  • c718b2c add a note
  • e32fb8b server starting button erroring on imports due to env differences
  • 1802818 working now
  • 194f50d using node_modules and allowing electron-builder to bundle it
  • 7782f2d ensuring deps are built before running server
  • 55e9113 unneeded mode
  • 3266319 exposing sync server via ngrok
  • b3e6d28 log msg for dev

📊 Changes

221 files changed (+26649 additions, -274 deletions)

View changed files

📝 bin/package-electron (+8 -1)
📝 package.json (+2 -0)
📝 packages/desktop-client/src/browser-preload.browser.js (+3 -0)
packages/desktop-client/src/components/manager/ConfigExternalSyncServer.tsx (+237 -0)
packages/desktop-client/src/components/manager/ConfigInternalSyncServer.tsx (+180 -0)
packages/desktop-client/src/components/manager/ConfigServer-failedattempt.tsx (+70 -0)
📝 packages/desktop-client/src/components/manager/ConfigServer.tsx (+76 -176)
📝 packages/desktop-client/src/components/manager/ManagementApp.tsx (+11 -1)
📝 packages/desktop-electron/index.ts (+229 -9)
📝 packages/desktop-electron/package.json (+3 -11)
📝 packages/desktop-electron/preload.ts (+12 -0)
📝 packages/loot-core/src/platform/server/asyncStorage/index.d.ts (+2 -2)
📝 packages/loot-core/src/server/main.ts (+6 -0)
📝 packages/loot-core/src/types/prefs.d.ts (+7 -0)
📝 packages/loot-core/typings/window.d.ts (+7 -0)
packages/sync-server/.dockerignore (+12 -0)
packages/sync-server/.editorconfig (+11 -0)
packages/sync-server/.eslintignore (+6 -0)
packages/sync-server/.eslintrc.cjs (+21 -0)
packages/sync-server/.gitignore (+33 -0)

...and 80 more files

📄 Description

NOTE: this branch has been around too long - check for merge fallout.

The goal

Free server hosting via the desktop app. We'd run the sync server inside of the desktop app, expose it to the internet via ngrok (or similar) and provide a QR code/url for the user to connect their phone to the server.

We could provide an option to start actual-server when the computer starts up. If we did this the server would be alive whenever the computer is on. If the user downloads the pwa to their phone they could budget even when the server is offline - it would sync when the computer is turned back on.

Todos:

  • Get the sync server working in the app
  • Expose the sync server using ngrok
  • Test this as my daily driver
  • Package the app and make it fully functional
  • Prevent error message "We had problems syncing your changes. Please report this as a bug by [opening a Github issue]" when the server is offline. I think it's because it hits ngrok first - ngrok can't connect to tunnel.
  • Fix server status appearing as offline when it finishes starting after web client loads #3128
  • Automatically set the server URL when the user uses the Electron Server. Update the UI to say that we're connected to "Local Server" or something instead of the server URL.
  • Socket hangup issue - when closing and opening the budget fresh when connected to ngrok server url.
    • I switched to udinci and it was still happening. It seems related to NGROK - I don't get it when I connect directly to the server.
    • When I connect via the web I don't get it at all.
    • This error can be avoided by connecting direct to localhost via electron and it doesn't occur on web/pwa. It's avoiding the error but not fixing it - but that may be satisfactory because it's better to connect to the server via localhost on electron for better offline functionality
  • Make progress towards getting the sync server in the main Actual repo
    • This will be done properly in a seperate PR - this is just a test branch
  • Change the server port to something else so it doesn't clash with local dev testing (not 5006)
  • Allow the server to run on https within localhost - this will require setting up a certificate - this can be optional - setup a server config ui?
    • Make the electron app manage the SSL so that users don't have to set it up
  • Build the UI
    • on server setup page when electron, push people towards using this functionality - still allow external server functionality
    • a settings area/modal to allow server configuration for initial setup and edits - Should probably live on file management page and under the server status dropdown.
    • a start and stop functionality for the server under the server status dropdown
  • Tidy the code
  • Test on
    • Window
    • Linux
    • Mac

In a follow up feature:

  • Provide an option to start actual-server when the computer starts up

Known issues

  • server /info endpoint isn't returning data - it means we can't see what version the server is on. I think it's to do with it not finding the package.json file. We're using an external package for it.

Next: Figure out the best way to bring actual-server into the actual repo

Expose the running server to the internet

Manged to get it working with ngrok. Ngrok's big and they give you a free domain. It works a treat. I haven't tested it in anger, I'm sure it will disconnect me after an hour or so so we may need to add logic to reconnect.

Thoughts on bundling the actual-server code

  • If actual-server was in the actual repo we could bundle using electron-builder. The package size seemed good when I tried that. This seems like the right way forward for all kinds of reasons - some not related to electron - type sharing, debugging, simlicity etc.

Old thoughts:

  • Actual-server bundle is huge - consider using webpack or https://github.com/vercel/ncc . Webpack seems promising, they have targets for electron and node.
  • BetterSqlite3 is complaining that it was compiled for server on a different version of node than electron. We'll also run into the arch issue so we'll need to fully make that external in the actual-server bundle and use the one we have in electron.
  • If we bundle, the bundle should only be used for electron (if we want to bundle for normal use it will be a separate bundle)

Server sync notes

  • We could warn the client against syncing if the client version is greater than the server version.
    • This means we should never have out of sync migrations
    • We'd always know the server version & client version at this point - we would have already migrated but we wont sync it with the server unless it is safe to do so.
    • Downside - if it takes 2 weeks to update the server the user is unable to sync until it is updated

🔄 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/3631 **Author:** [@MikesGlitch](https://github.com/MikesGlitch) **Created:** 10/10/2024 **Status:** ❌ Closed **Base:** `master` ← **Head:** `electron/server-hosting` --- ### 📝 Commits (10+) - [`20e2ef2`](https://github.com/actualbudget/actual/commit/20e2ef27b2e72858ca673131de2ca0197d862040) start to this epic idea - [`361200e`](https://github.com/actualbudget/actual/commit/361200e26c3d76fa30ed436c6ba6da17da9b60da) bits - [`c718b2c`](https://github.com/actualbudget/actual/commit/c718b2c442b34f5fa7ac4e2c0fcac8184c75b787) add a note - [`e32fb8b`](https://github.com/actualbudget/actual/commit/e32fb8b9589aa85ee83731847cc192b0fc016bdb) server starting button erroring on imports due to env differences - [`1802818`](https://github.com/actualbudget/actual/commit/1802818f2f340e2fd0cf2136e72c8371ae17d9fc) working now - [`194f50d`](https://github.com/actualbudget/actual/commit/194f50d889133bb2ceaf19e77f4d0985f975d15c) using node_modules and allowing electron-builder to bundle it - [`7782f2d`](https://github.com/actualbudget/actual/commit/7782f2dd6bb074efb4ed69002b9ebcdfafb3811f) ensuring deps are built before running server - [`55e9113`](https://github.com/actualbudget/actual/commit/55e91139c8e52b9dd13459149eaf853482d7e9d4) unneeded mode - [`3266319`](https://github.com/actualbudget/actual/commit/32663197626f010b4f0a5dc2f42b78ab66b54ae3) exposing sync server via ngrok - [`b3e6d28`](https://github.com/actualbudget/actual/commit/b3e6d28136ddfe1e4df1268e3284b1165dddd3a0) log msg for dev ### 📊 Changes **221 files changed** (+26649 additions, -274 deletions) <details> <summary>View changed files</summary> 📝 `bin/package-electron` (+8 -1) 📝 `package.json` (+2 -0) 📝 `packages/desktop-client/src/browser-preload.browser.js` (+3 -0) ➕ `packages/desktop-client/src/components/manager/ConfigExternalSyncServer.tsx` (+237 -0) ➕ `packages/desktop-client/src/components/manager/ConfigInternalSyncServer.tsx` (+180 -0) ➕ `packages/desktop-client/src/components/manager/ConfigServer-failedattempt.tsx` (+70 -0) 📝 `packages/desktop-client/src/components/manager/ConfigServer.tsx` (+76 -176) 📝 `packages/desktop-client/src/components/manager/ManagementApp.tsx` (+11 -1) 📝 `packages/desktop-electron/index.ts` (+229 -9) 📝 `packages/desktop-electron/package.json` (+3 -11) 📝 `packages/desktop-electron/preload.ts` (+12 -0) 📝 `packages/loot-core/src/platform/server/asyncStorage/index.d.ts` (+2 -2) 📝 `packages/loot-core/src/server/main.ts` (+6 -0) 📝 `packages/loot-core/src/types/prefs.d.ts` (+7 -0) 📝 `packages/loot-core/typings/window.d.ts` (+7 -0) ➕ `packages/sync-server/.dockerignore` (+12 -0) ➕ `packages/sync-server/.editorconfig` (+11 -0) ➕ `packages/sync-server/.eslintignore` (+6 -0) ➕ `packages/sync-server/.eslintrc.cjs` (+21 -0) ➕ `packages/sync-server/.gitignore` (+33 -0) _...and 80 more files_ </details> ### 📄 Description <!-- Thank you for submitting a pull request! Make sure to follow the instructions to write release notes for your PR — it should only take a minute or two: https://github.com/actualbudget/docs#writing-good-release-notes --> # NOTE: this branch has been around too long - check for merge fallout. # The goal Free server hosting via the desktop app. We'd run the sync server inside of the desktop app, expose it to the internet via ngrok (or similar) and provide a QR code/url for the user to connect their phone to the server. We could provide an option to start actual-server when the computer starts up. If we did this the server would be alive whenever the computer is on. If the user downloads the pwa to their phone they could budget even when the server is offline - it would sync when the computer is turned back on. **Todos:** - [x] Get the sync server working in the app - [x] Expose the sync server using ngrok - [x] Test this as my daily driver - [x] Package the app and make it fully functional - [x] Prevent error message "We had problems syncing your changes. Please report this as a bug by [opening a Github issue]" when the server is offline. I think it's because it hits ngrok first - ngrok can't connect to tunnel. - [x] Fix server status appearing as offline when it finishes starting after web client loads #3128 - [ ] Automatically set the server URL when the user uses the Electron Server. Update the UI to say that we're connected to "Local Server" or something instead of the server URL. - [x] Socket hangup issue - when closing and opening the budget fresh when connected to ngrok server url. - I switched to udinci and it was still happening. It seems related to NGROK - I don't get it when I connect directly to the server. - When I connect via the web I don't get it at all. - This error can be avoided by connecting direct to localhost via electron and it doesn't occur on web/pwa. It's avoiding the error but not fixing it - but that may be satisfactory because it's better to connect to the server via localhost on electron for better offline functionality - [x] Make progress towards getting the sync server in the main Actual repo - [x] This will be done properly in a seperate PR - this is just a test branch - [x] Change the server port to something else so it doesn't clash with local dev testing (not 5006) - [ ] Allow the server to run on https within localhost - this will require setting up a certificate - this can be optional - setup a server config ui? - [ ] Make the electron app manage the SSL so that users don't have to set it up - [ ] Build the UI - [ ] on server setup page when electron, push people towards using this functionality - still allow external server functionality - [ ] a settings area/modal to allow server configuration for initial setup and edits - Should probably live on file management page and under the server status dropdown. - [ ] a _start_ and _stop_ functionality for the server under the server status dropdown - [ ] Tidy the code - [ ] Test on - [x] Window - [ ] Linux - [ ] Mac In a follow up feature: - Provide an option to start actual-server when the computer starts up ## Known issues - server /info endpoint isn't returning data - it means we can't see what version the server is on. I think it's to do with it not finding the package.json file. We're using an external package for it. # Next: Figure out the best way to bring actual-server into the actual repo # Expose the running server to the internet Manged to get it working with ngrok. Ngrok's big and they give you a free domain. It works a treat. I haven't tested it in anger, I'm sure it will disconnect me after an hour or so so we may need to add logic to reconnect. # Thoughts on bundling the actual-server code - If actual-server was in the actual repo we could bundle using electron-builder. The package size seemed good when I tried that. This seems like the right way forward for all kinds of reasons - some not related to electron - type sharing, debugging, simlicity etc. Old thoughts: - Actual-server bundle is huge - consider using [webpack ](https://webpack.js.org/configuration/target/#root) or https://github.com/vercel/ncc . Webpack seems promising, they have targets for electron and node. - BetterSqlite3 is complaining that it was compiled for server on a different version of node than electron. We'll also run into the arch issue so we'll need to fully make that external in the actual-server bundle and use the one we have in electron. - If we bundle, the bundle should only be used for electron (if we want to bundle for normal use it will be a separate bundle) ## Server sync notes - We could warn the client against syncing if the client version is greater than the server version. - This means we should never have out of sync migrations - We'd always know the server version & client version at this point - we would have already migrated but we wont sync it with the server unless it is safe to do so. - Downside - if it takes 2 weeks to update the server the user is unable to sync until it is updated --- <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-02-28 21:03:58 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#4968