Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryptic error message if accounts.lock is locked #6636

Closed
Hocuri opened this issue Mar 10, 2025 · 5 comments
Closed

Cryptic error message if accounts.lock is locked #6636

Hocuri opened this issue Mar 10, 2025 · 5 comments
Labels
bug Something is not working

Comments

@Hocuri
Copy link
Collaborator

Hocuri commented Mar 10, 2025

How this happened to me:

Due to some bug deltachat/deltachat-desktop#4748, DC Desktop crashed but the accounts.lock stayed locked.

How DC Desktop crashed

I don't remember exactly what I did, but it was something along these lines:

  • Click "+" for new account
  • Press ESC
  • Try to select another account
  • -> DC Desktop is completely frozen
  • I closed DC

But when I try to reproduce this, everything works fine.

Steps to reproduce:

  • Lock the accounts.lock file using flock /home/.../DeltaChat/accounts/accounts.lock --command "sleep 1000"
  • Try to open Delta Chat

Actual behavior:

Image

Expected behavior:

A nice error message should be shown.

Possible solutions:

  • Make the error message nicer
  • Remove the locking of accounts.lock (this would also get us rid of one dependency, fd-lock) (see create_lock_task() in accounts.rs)
@Hocuri Hocuri added the bug Something is not working label Mar 10, 2025
@Simon-Laux
Copy link
Contributor

issue on desktop repo for reference: deltachat/deltachat-desktop#4748

@Septias
Copy link
Collaborator

Septias commented Mar 17, 2025

I invested this a bit and only the last part (after Fatal Error) is changeable in core/deltachat-rpc-server. The cryptic part originates (as @WofWca already pointed out in the desktop issue) from deltachat-desktop in this line https://github.com/deltachat/deltachat-desktop/blob/c0fdab6aa09dc640549d601077e3f44436fdcfc0/packages/target-electron/src/deltachat/stdio_server.ts#L96. So to solve this in core only the second proposal is a viable option.

@link2xt
Copy link
Collaborator

link2xt commented Mar 17, 2025

Remove the locking of accounts.lock (this would also get us rid of one dependency, fd-lock) (see create_lock_task() in accounts.rs)

When this happens, it is actually good that Delta Chat stops. If you forcefully unlock it while existing core is still running, both deltachat-rpc-server processes keep running, download messages and write each message to the database twice. The lock is working as intended.

From @hpk42 in desktop chat:

deleting the lock file was not enough -- i got double messages afterwards and it turned out there were two deltachat-rpc-server processes running. Had to kill the old one with "kill -9" to recover. Now everything is sane again.

@Hocuri
Copy link
Collaborator Author

Hocuri commented Mar 21, 2025

I made a PR that makes the core side of this look nicer: #6695

I'll create an issue in Desktop for the rest.

Hocuri added a commit that referenced this issue Mar 27, 2025
…#6695)

Targets #6636

Right now the error message is:

> Error: Delta Chat is already running. To use Delta Chat, you must
first close the existing Delta Chat process, or restart your device.
> 
> (accounts.lock lock file is already locked)

other suggestions welcome!
@Hocuri
Copy link
Collaborator Author

Hocuri commented Mar 27, 2025

Everything that's actionable for now has been done.

@Hocuri Hocuri closed this as completed Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working
Projects
None yet
Development

No branches or pull requests

4 participants