fix: stop Reddit's block page reading as a signed-out session
Reddit answers a throttled client with a large HTML 403 interstitial. To the comment client that was indistinguishable from a logged-out session: the body would not parse, so no modhash was found, so it reported "Reddit did not return a modhash for this session" and returned session-invalid — which calls auth.invalidate() and so could disrupt outreach and chat for an account whose session was perfectly healthy. That matches what prod is doing. u/Saira_Makimad posted successfully 25 seconds after boot and every later attempt failed with that message, which is the shape of Reddit starting to throttle rather than a session going bad. A response is now only treated as a verdict about the session when it is actually JSON. Non-JSON, at any status, is Reddit refusing to serve us and stays retryable. A genuine JSON 403, or JSON with no modhash, still invalidates as before. When Reddit does report a signed-out session, the log and the recorded reason now name the cookies visible to the write origin — names and domains only, never values. Cookies scoped to www.reddit.com rather than .reddit.com would produce exactly this symptom, and this makes that answerable from the logs instead of by guesswork. Also clarify the allowance in the dashboard. It is derived from the trust level rather than typed in, and it is a rolling 24-hour window, neither of which the page said. A per-community cap above the account allowance now says how much of it is actually reachable, because "1 of 10 today" next to an account limit of 2 reads as far more headroom than exists. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f36e93d5be
commit
f88db1ae7d
5 files changed
+240
-18
No files matched your search
@@ -21,6 +21,7 @@ import {
|
||||
} from '../database/account-repositories.js';
|
||||
import { RedditApiClient, RedditRateLimitError, type RedditPost } from '../reddit/api.js';
|
||||
import {
|
||||
REDDIT_WRITE_ORIGIN,
|
||||
RedditCommentClient,
|
||||
createAnonymousFetcher,
|
||||
createBrowserWriteTransport,
|
||||
@@ -258,6 +259,13 @@ async function buildRuntime(
|
||||
{
|
||||
scheduler: redditRequestCoordinator,
|
||||
anonymousFetch: createAnonymousFetcher(accountConfig.reddit.userAgent),
|
||||
// Names and domains only — never cookie values. This is the fastest way
|
||||
// to see why Reddit stopped recognising a session on the write origin.
|
||||
describeCookies: async () => {
|
||||
const cookies = await browserClient.getContext()?.cookies(REDDIT_WRITE_ORIGIN) ?? [];
|
||||
if (cookies.length === 0) return `none visible to ${REDDIT_WRITE_ORIGIN}`;
|
||||
return cookies.map((cookie) => `${cookie.name}@${cookie.domain}`).join(', ');
|
||||
},
|
||||
},
|
||||
);
|
||||
const growthService = new AccountGrowthService({
|
||||
|
||||
Reference in new issue
Block a user