FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: RecentPostsWidget TypeError with non-array posts by sentry[bot] · Pull Request #1185 · TanStack/tanstack.com · GitHub

fix: RecentPostsWidget TypeError with non-array posts - #1185

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/recent-posts-widget-array-check
Open

fix: RecentPostsWidget TypeError with non-array posts#1185
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/recent-posts-widget-array-check

Conversation

sentry Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: r.map is not a function occurring in the RecentPostsWidget when the fetchRecentPosts server function returns a non-array value (e.g., an error object).

Changes Made:

  1. src/components/RecentPostsWidget.tsx: Modified the conditional rendering logic from if (!visiblePosts) to if (!Array.isArray(visiblePosts)). This ensures that if fetchRecentPosts resolves to a non-array value (like an error object), the component correctly renders the RecentPostsSkeleton instead of attempting to call .map() on an invalid type, which caused the crash.
  2. src/utils/blog.functions.ts: Wrapped the body of the fetchRecentPosts handler in a try/catch block. In case of any error during post fetching, it now returns an empty array ([]). This provides a more robust server function that guarantees an array return type, preventing non-array payloads from ever reaching the client-side components.

Why these changes?
The original issue stemmed from fetchRecentPosts potentially returning an object (e.g., { error: "..." }) on failure. The RecentPostsWidget's guard !visiblePosts was insufficient as an object is truthy, and object.length is undefined, bypassing the check. Consequently, RecentPostsList received a non-array and crashed when calling .map(). These changes implement a more precise type check in the widget and a safer return value from the server function, resolving the TypeError and improving resilience.

Fixes TANSTACK-COM-4SC

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

Copy link
Copy Markdown

Deploying with    Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 5a29fad Commit Preview URL

Branch Preview URL
Aug 27 2026, 11:04 PM

tannerlinsley added the source-audit Tracked by the automated source audit label Aug 28, 2026
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

Labels

source-audit Tracked by the automated source audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL