Skip to content

fix: read comments again after Reddit's new comment IDs, and stop Phase 2 crashing - #105

Merged
Toldry merged 2 commits into
masterfrom
claude/project-thread-hp812u
Oct 25, 2026
Merged

Toldry merged 2 commits into
masterfrom
claude/project-thread-hp812u

Conversation

@Toldry

@Toldry Toldry commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Requested by Querent · project thread

Two problems found in the logs from 2026-10-25 20:57 to 22:17 UTC.

1. Comment reader read nothing since about 2026-10-21

Every heartbeat said scanned 0 comments, and every head poll was rejected. The r/all listing now returns IDs like 19rnei2yv8zk1 (about 6 × 10^18). Reddit announced on r/redditdev ("Upcoming changes to the comment ID endpoint", rolled out from the week of 2026-09-28) that new comment IDs are 64-bit, up to 13 base-36 characters, and "will not be monotonically increasing anymore". Two comments seconds apart are about 2 × 10^9 IDs apart, so reading blocks of 100 consecutive IDs can't work anymore. Third-party summary: https://www.redditapis.com/blogs/reddit-comment-ids-13-characters-2026

Change: CommentReader now polls the r/all comment listing.

  • It runs on STREAM_READERS threads, 12 by default (3 per account). Each thread asks for the newest 100 comments at most every 3 s, and the threads start staggered.
  • SeenComments (the last 20,000 fullnames) makes sure each comment is handed on once.
  • The heartbeat now shows new/request and gaps, which counts requests whose comments were all new, meaning comments in between were missed. It also warns whenever no comment was read during the interval.
  • STREAM_SOURCE=ids is removed and falls back to listing with a warning. The one-request PRAW stream is now STREAM_SOURCE=stream.
  • The ID-reader code, scripts/verify_comment_ids.py and the ID live tests are removed. New live tests cover the listing and a 45 s run of the real reader.
  • The stream_cursors table and DB functions are left in place, unused.
  • Docs (AGENTS.md, .env.example) are updated, and a changelog fragment is added.

Rate and egress: about 120 requests a minute with 12 readers, compared with about 75 for the ID reader. That stays within Reddit's 100 per minute per account. If the VM's .env still sets STREAM_READERS=4, that overrides the new default of 12.

2. Phase 2 crashed on every pass

Each pass ended with ClientException('No data returned for comment t1_phkdvpc'). The cause: the "comment unavailable" log line read permalink, which re-fetched a deleted comment and raised again (getattr's default only covers AttributeError). As a result, none of the 1,483 waiting comments got checked. permalink_safe now falls back to the ID.

Tests

uv run pytest: 1771 passed. The live tests run in CI after merge.

🤖 Generated with Claude Code

https://claude.ai/code/session_019J1tUq4uEQ6i91Nag6bzaa

When Reddit returned no data for a stored comment, the "comment
unavailable" log line read its permalink, which fetched it again and
raised ClientException (getattr's default only covers AttributeError).
Every Phase 2 pass since then crashed on the same deleted comment, so
none of the 1483 waiting comments were checked. The log line now falls
back to the comment ID.

Co-Authored-By: Toldry <toldry@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019J1tUq4uEQ6i91Nag6bzaa
@Toldry Toldry self-assigned this Oct 25, 2026
@Toldry
Toldry marked this pull request as ready for review October 25, 2026 22:22
Since about 2026-10-21 Reddit gives every new comment a 64-bit,
13-character ID that is no longer sequential (announced on r/redditdev),
so the reader that fetched blocks of 100 consecutive IDs read nothing
for days. CommentReader now polls the r/all comment listing on
STREAM_READERS threads (12 by default, 3 per account, each at most every
3 s), skips comments any thread saw before, and counts polls that may
have missed comments as gaps in the heartbeat. The heartbeat warns when
no comment was read in its interval. STREAM_SOURCE=ids is gone, the
single PRAW stream is now STREAM_SOURCE=stream, and the ID-reader
script and live tests are replaced by listing ones.

Co-Authored-By: Toldry <toldry@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019J1tUq4uEQ6i91Nag6bzaa
@Toldry Toldry changed the title fix: stop Phase 2 crashing on a comment Reddit no longer returns fix: read comments again after Reddit's new comment IDs, and stop Phase 2 crashing Oct 25, 2026
@Toldry
Toldry merged commit 5f90e8d into master Oct 25, 2026
4 checks passed
Toldry added a commit that referenced this pull request Oct 25, 2026
The master run after #105 failed because the test gallery was still
unprocessed after 30 s, so the deploy was skipped and the new comment
reader never went live. Wait up to 90 s and say what Reddit returned
when it times out.

Co-Authored-By: Toldry <toldry@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019J1tUq4uEQ6i91Nag6bzaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants