chore(calling): name the last Trouter status when the endpoint never arrives
- engine start failures now say token_failed, connect_failed or registrar_http_N - native_trouter_probe can register ringable and use native HTTP like the app Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -236,10 +236,13 @@ impl CallEngine {
236
236
.take_callbacks()
237
237
.ok_or_else(|| Error::Callback("callback stream already taken".into()))?;
238
238
let replier = realtime.callback_replier();
239
let mut last_status = None;
239
240
let endpoint = timeout(ENDPOINT_WAIT, async {
240
241
while let Some(event) = realtime.recv().await {
241
if let RealtimeEvent::Endpoint(endpoint) = event {
242
return Some(endpoint);
242
match event {
243
RealtimeEvent::Endpoint(endpoint) => return Some(endpoint),
244
RealtimeEvent::Status(status) => last_status = Some(format!("{:?} {}", status.kind, status.detail)),
245
_ => {}
243
246
}
244
247
}
245
248
None
@@ -249,7 +252,8 @@ impl CallEngine {
249
252
.flatten();
250
253
let Some(endpoint) = endpoint else {
251
254
realtime.stop().await;
252
return Err(Error::Callback("Trouter socket never announced its endpoint".into()));
255
let seen = last_status.map_or_else(|| "no status".to_owned(), |status| format!("last status: {status}"));
256
return Err(Error::Callback(format!("Trouter socket never announced its endpoint ({seen})")));
253
257
};
254
258
let identity = match fetch_self(&session).await {
255
259
Ok(identity) => identity,
@@ -236,10 +236,13 @@ impl CallEngine {236
.take_callbacks()236
.take_callbacks()237
.ok_or_else(|| Error::Callback("callback stream already taken".into()))?;237
.ok_or_else(|| Error::Callback("callback stream already taken".into()))?;238
let replier = realtime.callback_replier();238
let replier = realtime.callback_replier();239
let mut last_status = None;239
let endpoint = timeout(ENDPOINT_WAIT, async {240
let endpoint = timeout(ENDPOINT_WAIT, async {240
while let Some(event) = realtime.recv().await {241
while let Some(event) = realtime.recv().await {241
if let RealtimeEvent::Endpoint(endpoint) = event {242
match event {242
return Some(endpoint);243
RealtimeEvent::Endpoint(endpoint) => return Some(endpoint),244
RealtimeEvent::Status(status) => last_status = Some(format!("{:?} {}", status.kind, status.detail)),245
_ => {}243
}246
}244
}247
}245
None248
None@@ -249,7 +252,8 @@ impl CallEngine {249
.flatten();252
.flatten();250
let Some(endpoint) = endpoint else {253
let Some(endpoint) = endpoint else {251
realtime.stop().await;254
realtime.stop().await;252
return Err(Error::Callback("Trouter socket never announced its endpoint".into()));255
let seen = last_status.map_or_else(|| "no status".to_owned(), |status| format!("last status: {status}"));256
return Err(Error::Callback(format!("Trouter socket never announced its endpoint ({seen})")));253
};257
};254
let identity = match fetch_self(&session).await {258
let identity = match fetch_self(&session).await {255
Ok(identity) => identity,259
Ok(identity) => identity,@@ -2,14 +2,15 @@
2
2
use std::time::Duration;
3
3
4
4
use chatsvc::{Realtime, RealtimeConfig, RealtimeEvent};
5
use session::{DEFAULT_ENDPOINT, Session};
5
use session::{DEFAULT_ENDPOINT, Session, SessionConfig};
6
6
7
7
#[tokio::main]
8
8
async fn main() {
9
9
let seconds = std::env::args().nth(1).and_then(|value| value.parse().ok()).unwrap_or(60);
10
10
let endpoint = std::env::var("CDP_ENDPOINT").unwrap_or_else(|_| DEFAULT_ENDPOINT.to_owned());
11
let session = Session::connect(&endpoint).await.expect("browser");
12
let config = RealtimeConfig { native: true, initially_active: true, ..RealtimeConfig::default() };
11
let session = Session::connect_with(&endpoint, SessionConfig { native_http: std::env::var_os("PAGE_FETCH").is_none(), ..SessionConfig::default() }).await.expect("browser");
12
let ringable = std::env::var_os("RINGABLE").is_some();
13
let config = RealtimeConfig { native: true, initially_active: true, forward_callbacks: ringable, ringable, ..RealtimeConfig::default() };
13
14
let mut realtime = Realtime::start_with(&session, config).await.expect("realtime start");
14
15
println!("host {}", realtime.host());
15
16
let watch = async {
@@ -2,14 +2,15 @@2
use std::time::Duration;2
use std::time::Duration;3
3
4
use chatsvc::{Realtime, RealtimeConfig, RealtimeEvent};4
use chatsvc::{Realtime, RealtimeConfig, RealtimeEvent};5
use session::{DEFAULT_ENDPOINT, Session};5
use session::{DEFAULT_ENDPOINT, Session, SessionConfig};6
6
7
#[tokio::main]7
#[tokio::main]8
async fn main() {8
async fn main() {9
let seconds = std::env::args().nth(1).and_then(|value| value.parse().ok()).unwrap_or(60);9
let seconds = std::env::args().nth(1).and_then(|value| value.parse().ok()).unwrap_or(60);10
let endpoint = std::env::var("CDP_ENDPOINT").unwrap_or_else(|_| DEFAULT_ENDPOINT.to_owned());10
let endpoint = std::env::var("CDP_ENDPOINT").unwrap_or_else(|_| DEFAULT_ENDPOINT.to_owned());11
let session = Session::connect(&endpoint).await.expect("browser");11
let session = Session::connect_with(&endpoint, SessionConfig { native_http: std::env::var_os("PAGE_FETCH").is_none(), ..SessionConfig::default() }).await.expect("browser");12
let config = RealtimeConfig { native: true, initially_active: true, ..RealtimeConfig::default() };12
let ringable = std::env::var_os("RINGABLE").is_some();13
let config = RealtimeConfig { native: true, initially_active: true, forward_callbacks: ringable, ringable, ..RealtimeConfig::default() };13
let mut realtime = Realtime::start_with(&session, config).await.expect("realtime start");14
let mut realtime = Realtime::start_with(&session, config).await.expect("realtime start");14
println!("host {}", realtime.host());15
println!("host {}", realtime.host());15
let watch = async {16
let watch = async {