I have not had any issues with dpms off ever since I changed the line to only explicitly switch off the eDP output.
exec swayidle -w \
timeout 300 'swaymsg "output eDP-1 dpms off"' resume 'swaymsg "output eDP-1 dpms on"'
However, I have not tried this for very long yet, so I might just have been lucky to just not encounter the bug by chance.
Also, the system doesn’t completely freeze for me, only the graphical session. I can usually CTRL+ALT+F? to another terminal and kill Wayland.