Skip to content

Exiting Niri in a systemd service does not wait for graphical-session.target, causing some services to immediately fail due to losing the Wayland socket #2435

Description

@Frontear

It seems that niri.service exits before graphical-session.target is able to terminate, so services which come down alongside it are left in a broken state and usually terminate with error codes. Systemd then marks the system status as "degraded" due to the failed services.

The services which fail to shutdown is inconsistent, as their stop job is subject to race conditions. Ideally graphical-session.target is allowed to stop before Niri terminates, so that the wayland socket survives long enough.

Relevant journalctl output (last line is when graphical-session.target is stopped):

Sep 23 21:30:26 LAPTOP-3DT4F02 niri[117432]: 2025-09-24T01:30:26.607749Z  INFO niri::input: quitting after confirming exit dialog
Sep 23 21:30:26 LAPTOP-3DT4F02 niri[117432]: 2025-09-24T01:30:26.958939Z DEBUG niri::utils::watcher: exiting watcher thread for Regular { user_path: "/home/frontear/.config/niri/config.kdl">
Sep 23 21:30:26 LAPTOP-3DT4F02 .xdg-desktop-po[117540]: Lost connection to Wayland compositor.
Sep 23 21:30:26 LAPTOP-3DT4F02 .xdg-desktop-po[117583]: Error reading events from display: Broken pipe
Sep 23 21:30:26 LAPTOP-3DT4F02 .waybar-wrapped[117486]: Error reading events from display: Broken pipe
Sep 23 21:30:26 LAPTOP-3DT4F02 .thunar-wrapped[117483]: Error reading events from display: Broken pipe
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: wayland: failed to read events from the Wayland socket: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]:  err: wayland.c:1659: failed to read events from the Wayland socket: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: warn: server.c:74: client FD=8: terminal still alive
Sep 23 21:30:26 LAPTOP-3DT4F02 .swayosd-server[117482]: Lost connection to Wayland compositor.
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: server: client FD=8: terminal still alive
Sep 23 21:30:26 LAPTOP-3DT4F02 polkit-gnome-au[117477]: Error reading events from display: Broken pipe
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: niri.service: Consumed 34.070s CPU time, 159.5M memory peak.
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]:  err: wayland.c:2302: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]:  err: wayland.c:2302: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: wayland: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: wayland: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 polkitd[1867]: Unregistered Authentication Agent for unix-session:11 (system bus name :1.249, object path /org/gnome/PolicyKit1/AuthenticationAgent, locale en>
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: wayland: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:27 LAPTOP-3DT4F02 foot[117476]:  err: wayland.c:2302: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:27 LAPTOP-3DT4F02 foot[117476]: warn: server.c:74: client FD=20: terminal still alive
Sep 23 21:30:27 LAPTOP-3DT4F02 foot[117476]:  err: wayland.c:2302: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:27 LAPTOP-3DT4F02 foot[117476]:  err: wayland.c:2302: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:27 LAPTOP-3DT4F02 foot[117476]:  err: wayland.c:2302: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: polkit-gnome.service: Main process exited, code=exited, status=1/FAILURE
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: server: client FD=20: terminal still alive
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: polkit-gnome.service: Failed with result 'exit-code'.
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: wayland: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: Stopped GNOME PolicyKit Agent.
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: wayland: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: Stopped Idle manager for Wayland.
Sep 23 21:30:26 LAPTOP-3DT4F02 foot[117476]: wayland: failed to roundtrip Wayland display: Connection reset by peer
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: swayidle.service: Consumed 2.062s CPU time, 146.9M memory peak.
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: thunar.service: Main process exited, code=exited, status=1/FAILURE
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: thunar.service: Failed with result 'exit-code'.
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: Stopped thunar.service.
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: Stopped Dunst notification daemon.
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: xdg-desktop-portal-gnome.service: Main process exited, code=exited, status=1/FAILURE
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: xdg-desktop-portal-gnome.service: Failed with result 'exit-code'.
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: Stopped Portal service (GNOME implementation).
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: xdg-desktop-portal-gtk.service: Main process exited, code=exited, status=1/FAILURE
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: xdg-desktop-portal-gtk.service: Failed with result 'exit-code'.
Sep 23 21:30:26 LAPTOP-3DT4F02 systemd[1747]: Stopped Portal service (GTK/GNOME implementation).
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: swayosd.service: Main process exited, code=exited, status=1/FAILURE
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: swayosd.service: Failed with result 'exit-code'.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopped swayosd.service.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: swayosd.service: Consumed 1.302s CPU time, 28.8M memory peak.
Sep 23 21:30:27 LAPTOP-3DT4F02 foot[117476]:  err: wayland.c:2267: failed to flush wayland socket: Connection reset by peer
Sep 23 21:30:27 LAPTOP-3DT4F02 foot[117476]: wayland: failed to flush wayland socket: Connection reset by peer
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: waybar.service: Main process exited, code=exited, status=1/FAILURE
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: waybar.service: Failed with result 'exit-code'.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopped Highly customizable Wayland bar for Sway and Wlroots based compositors..
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: waybar.service: Consumed 2.512s CPU time, 25.1M memory peak.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: foot.service: Main process exited, code=exited, status=230/PERSONALITY
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopping microsoft-edge...
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopped target Startup of XDG autostart applications.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopping Portal service...
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopping flatpak document portal service...
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopping sandboxed app permission store...
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1]: run-user-1000-doc.mount: Deactivated successfully.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopped sandboxed app permission store.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopped Portal service.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopped flatpak document portal service.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopped microsoft-edge.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: app-niri-microsoft\x2dedge-763a6496.scope: Consumed 1min 51.233s CPU time, 1.2G memory peak.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: app-org.chromium.Chromium-118028.scope: Consumed 55.911s CPU time, 1.2G memory peak.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: foot.service: Failed with result 'exit-code'.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopped Fast, lightweight and minimalistic Wayland terminal emulator..
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: foot.service: Consumed 55.052s CPU time, 2.1G memory peak.
Sep 23 21:30:27 LAPTOP-3DT4F02 systemd[1747]: Stopped target Current graphical user session.

System Information

  • niri version: niri 25.08 (Nixpkgs)
  • Distro: NixOS
  • GPU: Intel Iris Xe Graphics
  • CPU: 11th Gen Intel(R) Core(TM) i7-1195G7

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:sessionScreen locking, idle inhibit, suspend/resume

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions