diff --git a/relay/remote_actor.py b/relay/remote_actor.py index a61a1d8..6b33a40 100644 --- a/relay/remote_actor.py +++ b/relay/remote_actor.py @@ -1,3 +1,4 @@ +import logging import aiohttp from . import CONFIG from .http_debug import http_debug @@ -15,7 +16,13 @@ async def fetch_actor(uri, force=False): if uri in ACTORS and not force: return ACTORS[uri] - async with aiohttp.ClientSession(trace_configs=[http_debug()]) as session: - async with session.get(uri, headers={'Accept': 'application/activity+json'}) as resp: - ACTORS[uri] = (await resp.json(encoding='utf-8', content_type=None)) - return ACTORS[uri] + try: + async with aiohttp.ClientSession(trace_configs=[http_debug()]) as session: + async with session.get(uri, headers={'Accept': 'application/activity+json'}) as resp: + if resp.status_code != 200: + return None + ACTORS[uri] = (await resp.json(encoding='utf-8', content_type=None)) + return ACTORS[uri] + except Exception as e: + logging.info('Caught %r while fetching actor %r.', e, uri) + return None