Avoid stack overflow when fetching deeply nested comments (#124)
This commit is contained in:
parent
2079b82de7
commit
027b386514
1 changed files with 7 additions and 3 deletions
|
@ -146,6 +146,10 @@ where
|
|||
Object::read_from_id(*id, data).await
|
||||
}
|
||||
|
||||
/// Fetch object from origin instance over HTTP, then verify and parse it.
|
||||
///
|
||||
/// Uses Box::pin to wrap futures to reduce stack size and avoid stack overflow when
|
||||
/// when fetching objects recursively.
|
||||
async fn dereference_from_http(
|
||||
&self,
|
||||
data: &Data<<Kind as Object>::DataType>,
|
||||
|
@ -154,7 +158,7 @@ where
|
|||
where
|
||||
<Kind as Object>::Error: From<Error>,
|
||||
{
|
||||
let res = fetch_object_http(&self.0, data).await;
|
||||
let res = Box::pin(fetch_object_http(&self.0, data)).await;
|
||||
|
||||
if let Err(Error::ObjectDeleted(url)) = res {
|
||||
if let Some(db_object) = db_object {
|
||||
|
@ -166,8 +170,8 @@ where
|
|||
let res = res?;
|
||||
let redirect_url = &res.url;
|
||||
|
||||
Kind::verify(&res.object, redirect_url, data).await?;
|
||||
Kind::from_json(res.object, data).await
|
||||
Box::pin(Kind::verify(&res.object, redirect_url, data)).await?;
|
||||
Box::pin(Kind::from_json(res.object, data)).await
|
||||
}
|
||||
|
||||
/// Returns true if the object's domain matches the one defined in [[FederationConfig.domain]].
|
||||
|
|
Loading…
Reference in a new issue