Commit 8c11845
fix(network): honor opts.signal in agentDirectory adapter via race (Codex PR #496 round 5)
Codex review feedback: the previous revision dropped opts.signal in
the only production AgentDirectoryLookup, leaving the resolver's
documented cancellation guarantee unhonored. A slow SPARQL
findAgentByPeerId could outlive the caller's deadline.
DiscoveryClient itself doesn't (yet) accept an AbortSignal, but
honoring the contract at the adapter boundary is enough: the
adapter races the lookup against the abort signal, so when the
signal fires the resolver gets an immediate `null` and can move on
or surface a timeout. The underlying SPARQL fetch leaks (completes
in the background and its result is discarded), bounded by the
discovery client's own internal timeout. Acceptable trade-off
because:
- RFC 04 Phase 2 replaces this fallback path entirely
- the alternative (full DiscoveryClient signal threading) is out
of scope for this PR
- the leak is bounded by an existing internal timeout, not unbounded
The resolver pre-step `signal.aborted` check (added in round 3) still
prevents NEW agent-directory work from starting once the deadline
elapses; this round-5 race covers the case where the SPARQL is
already in flight when the signal fires.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent b74de52 commit 8c11845
1 file changed
Lines changed: 33 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1326 | 1326 | | |
1327 | 1327 | | |
1328 | 1328 | | |
1329 | | - | |
1330 | | - | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
1334 | | - | |
1335 | | - | |
1336 | | - | |
1337 | | - | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
1342 | | - | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
1343 | 1362 | | |
1344 | 1363 | | |
1345 | 1364 | | |
| |||
0 commit comments