eleurent / twitter-graph

Fetch and visualize the graph of your Twitter friends and followers.
392 stars 46 forks source link

Downloader loops forever for users following 0 accounts #27

Closed nadesai closed 2 years ago

nadesai commented 2 years ago

This is referenced in https://github.com/eleurent/twitter-graph/issues/15#issuecomment-950232393, but is likely significant enough to warrant a separate issue.

The script loops indefinitely when trying to fetch information for accounts that follow 0 people. The lack of contentful response from the API when requesting follows/friendships seems to be incorrectly interpreted as a rate limit.

eleurent commented 2 years ago

Interesting... I'm not sure how we should address this, if there is no way of differentiating this situation from a rate limit error :/ Does the api really return the error code 88 (rate limit) in this case?

Should we just stop after some number of unsuccessful attempts?

nadesai commented 2 years ago

No, I should be clear that I do not know what code is returned by the API. I only meant to say that from the perspective of the current codebase, the zero-following and rate-limit case look identical.

eleurent commented 2 years ago

Oh okay, but I guess that must be the case since that error code is being checked in the rate-limit handling logic. Do you know a twitter account that follows 0 people, so I can check what's going on?

nadesai commented 2 years ago

@dalailama is one such account (https://twitter.com/dalailama).

FlorentLefebvre commented 2 years ago

I put a small patch for this issue in this PR: https://github.com/eleurent/twitter-graph/pull/30

eleurent commented 2 years ago

That is fixed, I believe

nadesai commented 2 years ago

(Looks like the actual reason was a bug in the code. The code attempted to fetch from the API while not user_friends, but since the API returns an empty list, user_friends keeps the value [] for such users and the code continues to loop forever.)

eleurent commented 2 years ago

Yes exactly