Skip to content

fix(feed): prevent hydration mismatch from no-reblog filter - #1707

Closed
sentry[bot] wants to merge 1 commit into
developfrom
seer/fix/feed-list-hydration
Closed

sentry[bot] wants to merge 1 commit into
developfrom
seer/fix/feed-list-hydration

Conversation

@sentry

@sentry sentry Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: Cannot read properties of null (reading 'parentNode') that occurs during React hydration in the FeedList component.

Root Cause:
The FeedList component uses the no-reblog query parameter to filter entries. This filtering logic was applied immediately on the client-side via useMemo, while the server-side rendered HTML did not apply this filter (as useSearchParams returns null during SSR). This discrepancy led to a structural mismatch between the server-rendered DOM and the client's expected DOM, causing React to fail during hydration.

Solution:
The fix defers the application of the no-reblog filter until after the component has successfully hydrated on the client. A mounted state flag is introduced, initialized to false and set to true in a useEffect hook that runs only after the initial render. The useMemo hook that extracts and filters entries now only applies the no-reblog filter when mounted is true. This ensures that both the server and the initial client render produce the same unfiltered list, preventing the hydration mismatch and subsequent error.

Fixes ECENCY-NEXT-1FPX

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@feruzm

feruzm commented Sep 6, 2026

Copy link
Copy Markdown
Member

Closing. The feed route is rendered at request time (the page awaits searchParams and cookies()), and in the App Router useSearchParams() returns the same params on the server and on the first client render, so the server HTML and the hydrating client both apply the no-reblog filter. The feed layout already relies on that to pick the eager thumbnail preload from the same filtered list. Every sampled event on a feed page had an empty query string, so ?no-reblog=true was not active on any of them.

ECENCY-NEXT-1FPX is the warning-level catch-all that sentry-before-send.ts creates on purpose for React's inline $RS script failing after a hydration mismatch or a chunk load failure. Its frames are in the HTML document, not in app code, and almost all of its volume is automation traffic on post pages. The change would also regress the feature: a hard load of ?no-reblog=true would render reblogs in the server HTML and remove them after mount, and every feed load would get an extra post-mount render.

@feruzm feruzm closed this Sep 6, 2026
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