Commit 070116a
authored
fix(agent): tighten idle-drain lifecycle from PR review
Address Greptile review comments on the idle drainer:
- interrupt(): await settleIdleDrainStop() after query.interrupt() so a drainer
that is mid-forward (awaiting client.sessionUpdate) fully exits before
interrupt() returns, closing the window where it could emit an event for an
already-cancelled session.
- startIdleDrain scheduling: capture the session at schedule time and bail in
the microtask if this.session was swapped (e.g. by refreshSession) before it
runs, so the drainer can't tag new-query events with the old session id.
- Document the single-drainer invariant on the startIdleDrain guard: because a
drainer holding a handoff keeps this.idleDrain non-null until
settleIdleDrainStop clears it, no second drainer can be assigned in that
window (the third review comment was self-correcting, not a bug).
Adds a test asserting cancel() while idle-draining awaits the drainer's exit.
Generated-By: PostHog Code
Task-Id: 39548658-f313-445b-bd1c-d07eaf9281cf1 parent 1a98164 commit 070116a
2 files changed
Lines changed: 41 additions & 2 deletions
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
235 | 252 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1223 | 1223 | | |
1224 | 1224 | | |
1225 | 1225 | | |
1226 | | - | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
1227 | 1236 | | |
1228 | 1237 | | |
1229 | 1238 | | |
1230 | 1239 | | |
1231 | 1240 | | |
1232 | 1241 | | |
1233 | 1242 | | |
1234 | | - | |
| 1243 | + | |
| 1244 | + | |
1235 | 1245 | | |
1236 | 1246 | | |
1237 | 1247 | | |
| |||
1255 | 1265 | | |
1256 | 1266 | | |
1257 | 1267 | | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
1258 | 1275 | | |
1259 | 1276 | | |
1260 | 1277 | | |
| |||
1355 | 1372 | | |
1356 | 1373 | | |
1357 | 1374 | | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
1358 | 1380 | | |
1359 | 1381 | | |
1360 | 1382 | | |
| |||
0 commit comments