fix: Don't check health for unsigned requests

This commit is contained in:
timedout committed 2026-12-04 12:21:05 +00:00
1 parent 2f356eaa91
commit b305b765f1
1 file changed
+16 -1
+16 -1
View File
@@ -1,4 +1,5 @@
use std::{
any::TypeId,
borrow::Cow,
fmt::Debug,
mem,
@@ -125,6 +126,7 @@ impl super::Service {
where
T: OutgoingRequest<PathBuilder: PathBuilder<Input<'i> = PathBuilderInput>> + Send,
PathBuilderInput: FederationPathBuilderInput,
<T as ruma::api::Metadata>::Authentication: 'static,
{
if !self.services.server.config.allow_federation {
return Err!(Config("allow_federation", "Federation is disabled."));
@@ -136,7 +138,20 @@ impl super::Service {
))));
}
self.ensure_remote_is_healthy(dest)?;
// Don't check health on unauthenticated requests, since those are only
// for keys and manual pings, which want to bypass health tracking
// anyway.
//
// TODO(nex): We should probably do a proper builder pattern for
// requests, since callers may wish to tune
// - Authentication (signed vs unsigned)
// - Health check activity
// - Timeout (normal vs slow)
// and having a billion functions and conditions for all of those is not
// ideal.
if TypeId::of::<T::Authentication>() != TypeId::of::<NoAuthentication>() {
self.ensure_remote_is_healthy(dest)?;
}
/// How long to wait with re-resolution if a server fails to resolve
const UNRESOLVABLE_RETRY_AFTER: Duration = Duration::from_hours(24 * 90);