Skip to content

Commit 44a966e

Browse files
authored
chore(http-handler): Add a 1 second timeout when creating a subscriber in call-v3 handler (#716)
1 parent f6bff7d commit 44a966e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

rs/http_endpoints/public/src/call/call_v3.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ use std::{
4343
use tokio_util::time::FutureExt;
4444
use tower::{util::BoxCloneService, ServiceBuilder};
4545

46+
/// The timeout duration used when creating a subscriber for the ingres message,
47+
/// by calling [`IngressWatcherHandle::subscribe_for_certification`].
48+
const SUBSCRIPTION_TIMEOUT: Duration = Duration::from_secs(1);
49+
4650
enum CallV3Response {
4751
Certificate(Certificate),
4852
UserError(UserError),
@@ -191,11 +195,9 @@ async fn call_sync_v3(
191195

192196
let message_id = ingress_submitter.message_id();
193197

194-
let timeout = Duration::from_secs(ingress_message_certificate_timeout_seconds);
195-
196198
let certification_subscriber = match ingress_watcher_handle
197199
.subscribe_for_certification(message_id.clone())
198-
.timeout(timeout)
200+
.timeout(SUBSCRIPTION_TIMEOUT)
199201
.await
200202
{
201203
Ok(Ok(message_subscriber)) => Ok(message_subscriber),
@@ -250,7 +252,9 @@ async fn call_sync_v3(
250252

251253
match certification_subscriber
252254
.wait_for_certification()
253-
.timeout(timeout)
255+
.timeout(Duration::from_secs(
256+
ingress_message_certificate_timeout_seconds,
257+
))
254258
.await
255259
{
256260
Ok(()) => (),

0 commit comments

Comments
 (0)