RequestTimeoutTracker class
Tracks per-request timeouts for critical JSON-RPC methods.
Each call to track starts a Timer keyed by the request ID. If the timer fires before resolve is called for that ID, the onTimeout callback is invoked with the method name, request ID, and timeout duration. This enables the SignalingHealthMonitor to detect stalled signaling and trigger recovery.
Design notes:
Constructors
- RequestTimeoutTracker({required void onTimeout(String method, String requestId, int timeoutMs), int defaultTimeoutMs = 10000})
-
Creates a tracker that fires
onTimeoutwhen a tracked request exceeds its timeout.
Properties
- defaultTimeoutMs → int
-
Default timeout in milliseconds when not overridden per-request.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasPending → bool
-
Whether any timers are active.
no setter
- onTimeout → void Function(String method, String requestId, int timeoutMs)
-
Called when a tracked request's timeout expires before a response
arrives. Parameters are (method, requestId, timeoutMs).
final
- pendingCount → int
-
The number of currently pending (unresolved) timers.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancelAll(
) → void - Cancel all pending timers and clear the tracker.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolve(
String requestId) → void - Resolve a request — cancels its timeout timer.
-
toString(
) → String -
A string representation of this object.
inherited
-
track(
String requestId, String method, {int? timeoutMs}) → void - Start tracking a request. Call this right before sending the request.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited