Commit da0785b
fix(daemon): recover acceptLoop panics (#1305)
## What?
Adds a top-level `defer func() { recover(); log }()` to
`(*Daemon).acceptLoop` so a panic in the accept goroutine logs with a
stack trace instead of taking down the whole daemon.
Closes #1119
## Why?
`daemon/daemon.go:120` launches `go d.acceptLoop()` with no panic
recovery. A panic inside the loop (or in `addClient` /
`daemonrpc.NewConn`) propagates up and the runtime aborts the process.
The sync loop, IDLE watcher, and connected clients all die with it. The
issue notes the same risk applies to the prior recovery fixes (#979 /
#980 / #981).
The recovery pattern matches the existing one at `main.go:4089`: log the
panic with a `runtime/debug.Stack()` trace and let the goroutine exit.
The daemon stops accepting new connections after a recovered panic, but
already-connected clients and the background sync loop keep running,
which is what the issue body asks for.1 parent f9c8767 commit da0785b
1 file changed
Lines changed: 23 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
196 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
197 | 212 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | 213 | | |
202 | 214 | | |
203 | 215 | | |
| |||
0 commit comments