Skip to content

Fix Mark read hanging the app by marking entries in one bulk request - #26

Merged
jgordijn merged 1 commit into
mainfrom
t3/b287fafc
Oct 13, 2026
Merged

jgordijn merged 1 commit into
mainfrom
t3/b287fafc

Conversation

@jgordijn

Copy link
Copy Markdown
Owner

Problem

"Mark read" sent one PATCH per loaded entry (up to 200) in parallel. For each one PocketBase:

  • loaded, validated and re-serialized the full entry, including raw_content, and
  • broadcast a realtime update event 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

  • New POST /api/entries/mark-read endpoint ({ids, is_read}, max 1000 ids). It updates is_read and updated with a single SQL UPDATE.
  • The feed's "Mark read" and "Undo" both use it.

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_content each, clicking Mark read → All entries:

API requests
main 602 (200 PATCH + 402 GET)
this PR 3 (1 POST + 2 GET)
  • go test ./internal/... -count=1 passes, including the new mark_read_test.go.
  • bunx vitest run: the 3 failures in daily-news/page.test.ts also fail on main.

🤖 Generated with Claude Code

"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>
@jgordijn
jgordijn merged commit 9a30aa0 into main Oct 13, 2026
1 check passed
@jgordijn
jgordijn deleted the t3/b287fafc branch October 13, 2026 15:06
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.

1 participant