bug: Intermittent React error #185 from non-memoized Fuse instances in kea selectors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39.9k
- Forks
- 3.4k
- Avg merge
- 6h 51m
- Merged PRs (30d)
- 232
Description
Bug Description
Bug description
Intermittent React error #185 ("Maximum update depth exceeded") crashes occurring across the PostHog app. This causes the page to become unresponsive, requiring a refresh.
The root cause is kea selectors that create new object references on every evaluation (primarily new Fuse(...) instances for search functionality). When React's useSyncExternalStore detects the "changed" reference, it triggers a re-render, which evaluates the selector again, creating another new reference — causing an infinite loop until React's safety limit (50 nested updates) is hit.
Affected logic files include membersLogic, settingsLogic, dashboardsLogic, infiniteListLogic, playerInspectorLogic, environmentsSwitcherLogic, and ~15 others.
Impact: 22 occurrences in the past 30 days. Low frequency, self-recovering (refresh fixes it).
How to reproduce
Difficult to reproduce reliably — requires specific timing conditions:
- Navigate to a page using one of the affected logic files
- Trigger a state update (e.g., data loads, search input) at the exact moment components are mounting/updating
- Race condition causes the infinite loop
Additional context
Error tracking: https://us.posthog.com/error_tracking/0199e97c-b0a1-75f3-a6c6-8b8782f1c1da
Debug info
Kind: bug
Target area: data_management
Report event: http://go/ticketByUUID/b93b55b2-1adb-47a6-a608-b4ba3460f28f
Session: https://us.posthog.com/project/sTMFPsFhdP1Ssg/replay/019c0352-d93f-7eb0-b999-de4fd1074e99?t=5328
Exceptions: https://us.posthog.com/project/2/error_tracking?filterGroup=%7B%22type%22%3A%22AND%22%2C%22values%22%3A%5B%7B%22type%22%3A%22AND%22%2C%22values%22%3A%5B%7B%22key%22%3A%22%24session_id%22%2C%22value%22%3A%5B%22019c0352-d93f-7eb0-b999-de4fd1074e99%22%5D%2C%22operator%22%3A%22exact%22%2C%22type%22%3A%22event%22%7D%2C%7B%22type%22%3A%22hogql%22%2C%22key%22%3A%22uuid%20%3D%20'019c03a2-d0da-7515-99a4-015e2f3dc66b'%22%2C%22value%22%3Anull%7D%5D%7D%5D%7D
Location: https://us.posthog.com/project/259120/data-management/ingestion-warnings
Persons-on-events mode for project: person_id_override_properties_on_events
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the selectors in membersLogic, settingsLogic, dashboardsLogic, infiniteListLogic, playerInspectorLogic, environmentsSwitcherLogic, and the other affected logic files. Trace where Fuse instances or other object references are created during selector evaluation and review the surrounding React subscription behavior. Done means the affected selectors return stable references across evaluations and the intermittent maximum-update-depth error no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100