Skip to content

fix: RecentPostsWidget TypeError when query returns non-array - #1201

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

fix: RecentPostsWidget TypeError when query returns non-array#1201
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/recent-posts-widget-type-error

Conversation

@sentry

@sentry sentry Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: r.map is not a function occurring in the RecentPostsWidget component.

Problem:
The RecentPostsWidget component was crashing when the fetchRecentPosts query (via recentPostsQuery.data) returned a truthy value that was not an array (e.g., a JSON error object or intercepted HTML from Cloudflare). The existing guard if (!visiblePosts) only checked for falsy values, allowing non-array objects to be passed to RecentPostsList, where posts.map() would then fail.

Solution:
Modified the conditional check in src/components/RecentPostsWidget.tsx on line 104 from if (!visiblePosts) to if (!visiblePosts || !Array.isArray(visiblePosts)). This ensures that if recentPostsQuery.data is not an array, the component will correctly render the RecentPostsSkeleton fallback, preventing the TypeError and improving the robustness of the widget.

Fixes TANSTACK-COM-4EW

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  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 868bbc8 Commit Preview URL

Branch Preview URL
Aug 31 2026, 11:04 AM
@tannerlinsley tannerlinsley added the source-audit Tracked by the automated source audit label Aug 31, 2026
@tannerlinsley

Copy link
Copy Markdown
Member

Source audit note: PR #1185 already addresses the same RecentPostsWidget map TypeError and contains the same client-side array guard. This PR is the narrower duplicate, but neither PR establishes how the server function, which is typed and implemented to return RecentPost[], produced a non-array runtime payload. Please consolidate these rather than merge both, and use the Sentry transport payload to decide whether the client guard is the right owner.

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

1 participant