Skip to content

fix: follow several people in a row without cancelling the earlier follows - #573

Merged
nunomaduro merged 1 commit into
dev-null-sh:productionfrom
rohitsasi720:fix/follow-several-in-a-row
Oct 19, 2026
Merged

nunomaduro merged 1 commit into
dev-null-sh:productionfrom
rohitsasi720:fix/follow-several-in-a-row

Conversation

@rohitsasi720

@rohitsasi720 rohitsasi720 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #559.

Problem

Following several people quickly from "Who to follow" only flipped the last button to Following. The others stayed on Follow, although the server had saved every follow: after a reload, all of them showed as followed.

FollowButton is an Inertia <Link>, so every follow is a regular visit. Inertia sends regular visits through a single-request stream, and starting a new visit interrupts the one in flight (syncRequestStream.interruptInFlight()). The first follow was cancelled in the browser (net::ERR_ABORTED) before its onSuccess ran, so its button never flipped, but the server still saved the follow, so the button and the database disagreed.

The same happened on every list with several follow buttons: followers and following, follow-back in notifications, and the empty log's suggestions.

Fix

FollowButton now sends async visits. These go through Inertia's non-interruptible stream, so follows run side by side and none cancels another, not even when you open a profile while a follow is on its way.

Async visits don't cancel a double click either, so each person's follow now waits for the previous one to finish. A per-user follow_pending value lives in the existing useSharedState store, and onBefore refuses a new visit while it is set, so two buttons for the same person (the aside and their profile) wait for each other too. The button gets aria-disabled meanwhile and keeps its size, so nothing shifts.

Stars and saves already work this way, through useHttp. This keeps follows on the redirect-back visits they already use, so nothing changes on the server.

Before and after

Before (production) After
Screen.Recording.2026-10-19.at.3.58.21.PM.mov
Screen.Recording.2026-10-19.at.3.47.06.PM.mov

Tests

  • tests/Unit/FollowState.test.tsx: two suggestions followed in a row both send async visits and both end up showing "Following", and a second click on a follow still on its way sends nothing. Both tests fail on production and pass here, and all 15 tests in the file pass.
  • bun run test:unit, bun run test:lint, bun run test:types, Pint, Rector, PHPStan and the full Pest suite (2,951 tests) pass locally. Coverage didn't run because I have no PCOV or Xdebug, but there is no PHP change.
  • With Slow 3G latency, clicking Follow on three suggestions 300 ms apart: on production the first two requests are aborted and their buttons stay on Follow while all three are saved; on this branch all three requests complete and all three buttons show Following. Checked by hand and with a Playwright script that compares each button with the database.

tests/Unit/*.test.tsx files don't run in CI yet (test:unit only globs *.test.ts, see #492), so I ran this one with bunx vp test run tests/Unit/FollowState.test.tsx.

…llows

Follow buttons were plain Inertia visits, and Inertia cancels the visit in
flight when the next one starts. Following a second person before the first
answered left the first button on "Follow". Follows are now async visits,
and each person's follow waits for the one before it to finish.

Fixes dev-null-sh#559
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.

You can't quickly follow multiple people from the "Who to follow" sidebar.

2 participants