Repository navigation
fix(post): send the post view only once the token is valid - #7555
Merged
Merged
Conversation
Opening a post straight from a push or email link loads the page cold. The user comes from the cached boot data right away, so the view effect fired viewPost before /boot had reissued the 15-minute access token. After a few hours away that token has expired, the API sees an anonymous request and answers UNAUTHENTICATED, and useViewPost treats that as a final rejection: the view is dropped, never retried, and the read is missing from history and the streak. Gate every mount-time view on isTokenValid, the flag the feed already waits on (token refreshed, or a cached token that is still valid), so the view goes out once the session is usable. Fixes dailydotdev/daily#2214
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
idoshamun
enabled auto-merge (squash)
December 3, 2026 09:18
…refs Touching BriefPostContent pulls it into typecheck_strict_changed, which flagged three existing RefObject<HTMLDivElement | null> props. Cast at the call site, as SnapshotSharePanel does.
This branch was successfully deployed
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.
Changes
Fixes dailydotdev/daily#2214: a post opened from a notification doesn't show up in reading history and doesn't count for the streak.
useTrackPostViewand the mount-time view effects in Brief, Social/Twitter, Poll and Digest posts now wait forisTokenValidbefore they sendviewPost. That's the same flag the feed already waits on: the token was refreshed, or the cached one is still valid.BriefPostContent.tsxnow falls under the strict typecheck, so its three snapshotcontainerRefprops get aRefObject<HTMLElement>cast at the call site, asSnapshotSharePaneldoes. These were existing errors, not new ones.useTrackPostView.spec.tsx: no view while the token is invalid, and exactly one once it becomes valid. It fails without the fix.Why: a push or email link loads the post page cold. The user comes from the cached boot data immediately, so
viewPostwent out before/boothad reissued the 15-minute access token. After hours away that token has expired, so the API sees an anonymous request and returnsUNAUTHENTICATED.isFinalViewRejectiontreats that as final, so the view is dropped and never retried. TheBootProviderrecovery after a token refresh only re-runs failed queries, not mutations.Evidence (Nov 19 – Dec 2). Same posts, logged-in users, opened via the reading reminder push vs opened in-app:
Nov 1–14 looked the same (Android 29%), so this isn't a recent regression.
Verification: the new spec, the shared
hooks/post,components/postandhooks/streakssuites (273 tests), the full webapp suite (705 tests),pnpm --filter webapp typecheckand oxlint/oxfmt all pass.typecheck-strict-changedpasses too. I haven't reproduced it on a device.Events
No new tracking events.
Experiment
No new experiments.
🤖 Opened by Smith (AI assistant) on behalf of @idoshamun.