Linus2punkt0 / bluesky-crossposter

An app for crossposting your posts from bluesky to twitter and mastodon
108 stars 23 forks source link

Creating a new session each attempt to read is tripping per-handle rate limit. #55

Open barberio opened 1 week ago

barberio commented 1 week ago

Following the increase of use, Blue Sky have tightened up the restrictions on per-handle rate-limits. This means that there is now a hard 100 Session creation limit per day, with new sessions being blocked for at least 24 hours after tripping the limiter.

As it appears that the crossposted uses a new session for every read, this uses up a chunk of the quota, someone who uses their account from multiple devices might find themselves locked out quickly.

Can you please implement checking the ratelimit header returned on requests to Bluesky and preventing requests that would take the handle over quota. (https://www.ietf.org/archive/id/draft-polli-ratelimit-headers-02.html)

For example, you could be handling this error to throttle session creation.

atproto_client.exceptions.RequestException: Response(success=False, status_code=429, content=XrpcError(error='RateLimitExceeded', message='Rate Limit Exceeded'), headers=Headers({'date': 'Wed, 18 Sep 2024 14:36:00 GMT', 'content-type': 'application/json; charset=utf-8', 'content-length': '61', 'connection': 'keep-alive', 'x-powered-by': 'Express', 'access-control-allow-origin': '*', 'ratelimit-limit': '100', 'ratelimit-remaining': '0', 'ratelimit-reset': '1726684000', 'ratelimit-policy': '100;w=86400', 'etag': '[REDACTED ETAG IDENTIFIER STRING]', 'vary': 'Accept-Encoding'}))

Linus2punkt0 commented 1 week ago

I'm going to look into a solution for this. As a temporary solution for my own instance I have limited how often and what hours my crossposter runs. I also saw the solution that you can self-host and then turn of ratelimits (https://github.com/bluesky-social/pds) but that felt like somewhat of a project.