agent-rs
agent-rs copied to clipboard
call_and_wait should add a delay between calls to request_status_raw
loop {
match self.agent.request_status_raw(&request_id).await? {
…
RequestStatusResponse::Unknown => (),
RequestStatusResponse::Received | RequestStatusResponse::Processing => {
// The system will return Unknown until the request is accepted
// and we generally cannot know how long that will take.
// State transitions between Received and Processing may be
// instantaneous. Therefore, once we know the request is accepted,
// we restart the waiter so the request does not time out.
if !request_accepted {
waiter
.restart()
.map_err(|_| AgentError::WaiterRestartError())?;
request_accepted = true;
}
}
…
};
will very aggressively hammer the read endpoint, possibly starving that node. [There should be some delays here.]
It seems we are using the Waiter to throttle. Are you using the proper Waiter instance?
https://github.com/dfinity/agent-rs/blob/next/ic-agent/src/agent/mod.rs#L603-L605
waiter
.wait()
.map_err(|_| AgentError::TimeoutWaitingForResponse())?;