Repository navigation
Fix Mark read hanging the app by marking entries in one bulk request - #26
Merged
Merged
Conversation
"Mark read" sent one PATCH per loaded entry (up to 200) in parallel. Each PATCH re-serialized the full entry including raw_content and broadcast a realtime event, and every event made the feed refetch two counts, so one click produced ~600 requests and exhausted the 256 MiB container (swap thrash, app hang). Add POST /api/entries/mark-read which updates is_read for a list of ids in one UPDATE statement, and use it for both mark-read and undo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
"Mark read" sent one PATCH per loaded entry (up to 200) in parallel. For each one PocketBase:
raw_content, andupdateevent with the full record.The feed handled every realtime event by refetching the unread and bookmarked counts. So a single click produced ~600 requests. On the 1 vCPU / 256 MiB LXC this filled RAM and swap and the app stalled (memory pressure stall ~80%, disk reads ~900 M from swapping).
Fix
POST /api/entries/mark-readendpoint ({ids, is_read}, max 1000 ids). It updatesis_readandupdatedwith a single SQLUPDATE.The bulk update skips the per-record realtime events, so other open tabs don't see the change until they reload. A follow-up PR restores that cheaply.
Verification
Headless Chromium against the real binary, 200 unread entries with ~54 KB of
raw_contenteach, clicking Mark read → All entries:maingo test ./internal/... -count=1passes, including the newmark_read_test.go.bunx vitest run: the 3 failures indaily-news/page.test.tsalso fail onmain.🤖 Generated with Claude Code