At a few minutes before 11:00 wlsunset went crazy. Before killing it I straced the process and got lots of these lines:
sendmsg(5, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\6\0\0\0\0\0\10\0", iov_len=8}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[7]}], msg_controllen=20, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = -1 EPIPE (Broken pipe)
poll([{fd=5, events=POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT|POLLHUP}])
Seems like the Wayland display connection died, with wlsunset handling EPIPE poorly.
Without knowing why the connection died I cannot fix the former. The latter should be fixed in cc9251d5c39ff3e4beb130306722d7b90d1031ab.
I think it's because I logged on and off a few times. Does wlsunset die with the sway session? If it remains running we have the cause of our problem.
wlsunset dies as intended when the wayland display is closed. If the timing is right, the error handling of this goes bad and you get the infinite loop.
If this was caused by shutting down sway rather than a protocol error, then the issue is fixed.