HydraIssues

hydrabody Windows scheduled task does not auto-restart on crash; Sunshine prep-cmd then fails with Error 0
open bug Project: hydrabody Reporter: cederik 30 Apr 2026 14:00

Description

## Symptom

Today (2026-04-30) on **cosmic-pretzel-98**, Sunshine returned `Failed to start the specified application (Error 0)` to Moonlight for *every* experience launch, regardless of which experience or which head was streaming. Mercator and Rupelmonde both failed identically with that error popup on the kiosk display.

## Root cause

`hydrabody` had crashed (or otherwise stopped) at some point earlier and the `HydraBody` scheduled task was reported `Status: Ready / Next Run Time: N/A` — i.e. not running, not scheduled to retry. The hydrabody process simply was absent.

Sunshine's `prep-cmd` for every experience in `apps.json` is:
```
curl.exe -s -X POST http://localhost:47991/api/v1/stream/started -H "Content-Type: application/json" -d "{\"app\":\"<name>\"}"
```
That endpoint is served by hydrabody on `:47991`. With hydrabody down, the curl returns no-listener (TCP RST). Sunshine treats prep-cmd failure as launch failure and reports the generic `Error 0` to the kiosk.

Recovery: `schtasks /end /tn HydraBody && schtasks /run /tn HydraBody` brought hydrabody back, after which streams worked immediately.

## Two-part fix

1. **Auto-restart on crash:** the `HydraBody` scheduled task needs `If the task fails, restart every X minutes` (Settings → restart on failure) configured. hydrabody's installer (`internal/cli/install_windows.go` or wherever the `schtasks /create` invocation lives) should add `/RI 1 /Z /F` or set `RestartCount` and `RestartInterval` programmatically via the Task Scheduler API. Also worth setting `MultipleInstancesPolicy=IgnoreNew` so duplicate launches don't pile up.

2. **Sunshine prep-cmd resilience:** even with auto-restart, there's a window during boot/restart where hydrabody is unavailable. Two options:
- Make the prep-cmd `curl` non-blocking (treat HTTP error as success) so hydrabody's notification is best-effort, not a launch gate.
- Or have hydrabody be the one that runs Sunshine entirely (process supervisor relationship), so Sunshine simply isn't running when hydrabody isn't — visitors get a clean "no body" error instead of a confusing per-app launch failure.

The auto-restart is the immediate fix; the prep-cmd resilience is the structural fix.

## Verification

Repro: `Stop-Process -Name hydrabody -Force` on a body, then trigger a stream from any kiosk. Expect: Error 0 popup. After fix: scheduled task should restart hydrabody within ≤1 minute, Sunshine prep-cmd succeeds, stream launches cleanly.

## Related

- Today's session at cosmic surfaced this as a side-effect of investigating venue planting; the reboot we did yesterday for #126 plus the hydrabody operations for that fix may have left the scheduled task in a stuck state.