Skip to content

Commit 8c47be3

Browse files
committed
fix inf loop about the version mismatches
1 parent 8699e25 commit 8c47be3

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

compute/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ async fn main() -> Result<()> {
8080
config.assert_address_not_in_use()?;
8181
// check services & models, will exit if there is an error
8282
// since service check can take time, we allow early-exit here as well
83+
//
84+
// NOTE: to test for erroneous compute nodes, you can simply disable this check
85+
// and use a bad API key for the model you want to test
8386
tokio::select! {
8487
result = config.workflows.check_services() => result,
8588
_ = cancellation.cancelled() => {

p2p/src/client.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -323,27 +323,33 @@ impl DriaP2PClient {
323323
cause,
324324
..
325325
} => {
326-
let cause = cause
327-
.map(|c| c.to_string())
328-
.unwrap_or("Unknown".to_string());
326+
// we only care about the connections that we have dialed
329327
if endpoint.is_dialer() {
330-
// we only care about logs about the ones that we have dialed
331-
log::warn!("Connection ({connection_id}) closed for {peer_id}\nCause: {cause}");
328+
// if we know the cause, it may be a good idea to re-dial
329+
if let Some(cause) = cause {
330+
log::warn!(
331+
"Connection ({connection_id}) closed for {peer_id} due to {cause}"
332+
);
332333

333-
let addr = endpoint.get_remote_address();
334-
log::info!("Dialing {} again at {}", peer_id, addr);
335-
if let Err(err) = self.swarm.dial(
336-
DialOpts::peer_id(peer_id)
337-
.addresses(vec![addr.clone()])
338-
.condition(PeerCondition::DisconnectedAndNotDialing)
339-
.build(),
340-
) {
341-
log::error!("Could not dial peer {peer_id}: {err:?}");
334+
let addr = endpoint.get_remote_address();
335+
log::info!("Dialing {} again at {}", peer_id, addr);
336+
if let Err(err) = self.swarm.dial(
337+
DialOpts::peer_id(peer_id)
338+
.addresses(vec![addr.clone()])
339+
.condition(PeerCondition::DisconnectedAndNotDialing)
340+
.build(),
341+
) {
342+
log::error!("Could not dial peer {peer_id}: {err:?}");
343+
}
344+
} else {
345+
// if we don't know the cause, we don't want to re-dial,
346+
// because the cause is `None` if the other side closed the connection manually
347+
log::warn!(
348+
"Connection ({connection_id}) closed for {peer_id} without a cause, will not re-dial!"
349+
);
342350
}
343351
} else {
344-
log::debug!(
345-
"Connection ({connection_id}) closed for {peer_id}\nCause: {cause}"
346-
);
352+
log::debug!("Connection ({connection_id}) closed for {peer_id}: {cause:?}",);
347353
}
348354
}
349355

0 commit comments

Comments
 (0)