DIYgod / RSSHub

🧡 Everything is RSSible
https://docs.rsshub.app
MIT License
33.79k stars 7.55k forks source link

Reduce Twitter token lock time from 24h to 1h for better service recovery #17580

Open AiraNadih opened 1 week ago

AiraNadih commented 1 week ago

Routes

/twitter/home/:routeParams?

Full routes

/twitter/home/onlyMedia=1

Related documentation

https://docs.rsshub.app/routes/social-media#x-twitter

What is expected?

When a Twitter token becomes invalid and login retry fails, the token should be locked for a reasonable time period (e.g., 1 hour).

What is actually happening?

Currently, when a token becomes invalid (403/401 response) and login retry fails, the code locks the token for 86400 seconds (24 hours). This is unnecessarily long and could cause extended service disruption even after the credentials are fixed.

Relevant code:

https://github.com/DIYgod/RSSHub/blob/091ed089301b942b916807f081e2316a9d04c125/lib/routes/twitter/api/web-api/utils.ts#L206

Deployment information

Self-hosted

Deployment information (for self-hosted)

No response

Additional info

Suggested changes:
1. Reduce the lock time from 86400 (24 hours) to 3600 (1 hour)
2. This shorter duration would:
   - Allow faster recovery after credential fixes
   - Improve service availability

This is not a duplicated issue

github-actions[bot] commented 1 week ago
Searching for maintainers:

To maintainers: if you are not willing to be disturbed, list your username in scripts/workflow/test-issue/call-maintainer.js. In this way, your username will be wrapped in an inline code block when tagged so you will not be notified.

If all routes can not be found, the issue will be closed automatically. Please use NOROUTE for a route-irrelevant issue or leave a comment if it is a mistake. 如果所有路由都无法匹配,issue 将会被自动关闭。如果 issue 和路由无关,请使用 NOROUTE 关键词,或者留下评论。我们会重新审核。

github-actions[bot] commented 1 week ago
Searching for maintainers:

To maintainers: if you are not willing to be disturbed, list your username in scripts/workflow/test-issue/call-maintainer.js. In this way, your username will be wrapped in an inline code block when tagged so you will not be notified.

If all routes can not be found, the issue will be closed automatically. Please use NOROUTE for a route-irrelevant issue or leave a comment if it is a mistake. 如果所有路由都无法匹配,issue 将会被自动关闭。如果 issue 和路由无关,请使用 NOROUTE 关键词,或者留下评论。我们会重新审核。

weskerty commented 1 week ago

Using TWITTER_AUTH_TOKEN="" TWITTER_COOKIE="auth_token=; ct0="

and Automating Tasker to Open Twitter in the Browser that has the same cookie solves the problem for me

AiraNadih commented 1 week ago

Using TWITTER_AUTH_TOKEN="" TWITTER_COOKIE="auth_token=; ct0="

and Automating Tasker to Open Twitter in the Browser that has the same cookie solves the problem for me

No, what you said is not the problem I mentioned.

Even with the correct auth token, I don't know why I'm getting 403/401 errors and then getting locked out for 24 hours.

weskerty commented 6 days ago

Even with the correct auth token, I don't know why I'm getting 403/401 errors and then getting locked out for 24 hours.

The browser must be active on Twitter with the official cookie or it will fail with those errors. That's why I talked about automation with Tasker to browse Twitter every so often.

AiraNadih commented 5 days ago

Even with the correct auth token, I don't know why I'm getting 403/401 errors and then getting locked out for 24 hours.

The browser must be active on Twitter with the official cookie or it will fail with those errors. That's why I talked about automation with Tasker to browse Twitter every so often.

However, in commit 42a10b9, TWITTER_COOKIE was replaced by TWITTER_AUTH_TOKEN.

I don't know why you're still using TWITTER_COOKIE, as it's no longer meaningful.

And the above situation returned to normal after I manually cleared the stupid 86400-second lock and then restarted RSSHub.

AiraNadih commented 5 days ago

The 86400-second lock was added in commit f107701.

weskerty commented 5 days ago

I don't know why you're still using TWITTER_COOKIE, as it's no longer meaningful.

If I delete that line for some reason the bot doesn't work for me