Skip to content

[Bug] [Flatpak] Stale KDSingleApplication lock file prevents launch after logout/login #9796

@Aqua1ung

Description

@Aqua1ung

Component: Nextcloud Desktop (Flatpak)

Version: 33.0.0daily (Flatpak)

OS: blendOS (Arch Linux), GNOME/Wayland

Description

After a logout/login cycle (not a reboot), the Nextcloud Desktop Flatpak client fails to start. The app immediately exits with status 255, logging "Already running, exiting...".

The cause is a stale lock file at:

~/.var/app/com.nextcloud.desktopclient.nextcloud/cache/tmp/kdsingleapp-dad-nextcloud.lock

KDSingleApplication creates this lock to enforce single-instance behavior, but it is not cleaned up when the session ends via logout. On the next login, the new instance finds the lock file, assumes another instance is running, and exits.

Steps to reproduce

  1. Launch Nextcloud Desktop (Flatpak) — it runs normally
  2. Log out of the GNOME session
  3. Log back in
  4. Nextcloud Desktop fails to start (autostart or manual launch)

Journal output

nextcloud.gui.application: Already running, exiting...
dbus-:1.2-com.nextcloudgmbh.Nextcloud@0.service: Main process exited, code=exited, status=255/EXCEPTION

Workaround

rm ~/.var/app/com.nextcloud.desktopclient.nextcloud/cache/tmp/kdsingleapp-dad-nextcloud.lock

Expected behavior

KDSingleApplication should detect stale locks — for example by using flock() (which auto-releases when the process dies) or by recording the PID in the lock file and checking if it's still alive. Alternatively, Nextcloud could register a cleanup handler for SIGTERM/session-end signals.

Additional context

This likely happens because the Flatpak sandbox receives SIGKILL during logout before the app has time to clean up, or because SIGTERM isn't properly forwarded through the Flatpak/systemd scope. The issue does not occur after a full reboot (since /run/user/ or $XDG_CACHE_HOME/tmp gets wiped).

A secondary issue is that config migration from data/Nextcloud to config/Nextcloud also fails repeatedly for sync log files that exist in both locations, producing log noise on every launch.

File against

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions