You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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
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.
This PR addresses a
TypeError: Cannot read properties of null (reading 'parentNode')that occurs during React hydration in theFeedListcomponent.Root Cause:
The
FeedListcomponent uses theno-reblogquery parameter to filter entries. This filtering logic was applied immediately on the client-side viauseMemo, while the server-side rendered HTML did not apply this filter (asuseSearchParamsreturnsnullduring 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-reblogfilter until after the component has successfully hydrated on the client. Amountedstate flag is introduced, initialized tofalseand set totruein auseEffecthook that runs only after the initial render. TheuseMemohook that extracts and filters entries now only applies theno-reblogfilter whenmountedistrue. 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.