fix(ws): suppress deferred-API RPC error events for opt-in callers (#1265)
Co-authored-by: m57 <41645758+Hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
ae9003decd
commit
8f40f028e0
2 files changed
+21
-2
No files matched your search
@@ -775,6 +775,7 @@ object HermesWsClient {
|
||||
val method: String,
|
||||
val deferred: CompletableDeferred<Any?>,
|
||||
var timeoutJob: Job? = null,
|
||||
val suppressErrorEvent: Boolean = false,
|
||||
)
|
||||
|
||||
/** Tracks in-flight [request] calls by their JSON-RPC id. */
|
||||
@@ -794,11 +795,12 @@ object HermesWsClient {
|
||||
method: String,
|
||||
params: Map<String, Any> = emptyMap(),
|
||||
timeoutMs: Long = REQUEST_TIMEOUT_MS,
|
||||
suppressErrorEvent: Boolean = false,
|
||||
): CompletableDeferred<Any?> {
|
||||
val deferred = CompletableDeferred<Any?>()
|
||||
val id =
|
||||
send(method, params) { reqId ->
|
||||
pendingCalls[reqId] = PendingCall(method, deferred)
|
||||
pendingCalls[reqId] = PendingCall(method, deferred, suppressErrorEvent = suppressErrorEvent)
|
||||
}
|
||||
deferred.invokeOnCompletion { cause ->
|
||||
if (cause is CancellationException) {
|
||||
@@ -1458,6 +1460,16 @@ object HermesWsClient {
|
||||
disconnectIfIdleInBackground()
|
||||
}
|
||||
}
|
||||
if (pendingCalls[event.id]?.suppressErrorEvent == true) {
|
||||
// Opt-in suppression: the caller already handles the
|
||||
// failure through the CompletableDeferred, so the event
|
||||
// copy would only surface a duplicate UI banner for
|
||||
// optional features (e.g. "subagent.list" on gateways
|
||||
// without the method, issue #1089). Default request()
|
||||
// behavior still emits the event for shared consumers.
|
||||
resolvePending(event.id, null, event.error)
|
||||
return
|
||||
}
|
||||
removeQueuedMessage(event.id)
|
||||
resolvePending(event.id, null, event.error)
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ object SubagentRepository {
|
||||
.request(
|
||||
WsMethods.SUBAGENT_LIST,
|
||||
mapOf("session_id" to sessionId),
|
||||
suppressErrorEvent = true,
|
||||
).await()
|
||||
decode<SubagentListResponse>(result)
|
||||
} catch (e: Exception) {
|
||||
@@ -65,7 +66,13 @@ object SubagentRepository {
|
||||
if (sessionId.isNotBlank()) {
|
||||
params["session_id"] = sessionId
|
||||
}
|
||||
val result = HermesWsClient.request(WsMethods.SUBAGENT_TAIL, params).await()
|
||||
val result =
|
||||
HermesWsClient
|
||||
.request(
|
||||
WsMethods.SUBAGENT_TAIL,
|
||||
params,
|
||||
suppressErrorEvent = true,
|
||||
).await()
|
||||
return decode<SubagentTailResponse>(result)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user