Repository navigation
fix(fanout): complete aggregation, bounded fetches, real error messages - #428
Merged
Merged
Conversation
…umanize errors Fixes #427 (three of its four findings; the Track-path round-trip reduction is intentionally left out as a separate optimization): - getQueryFanout/getPromptFanout now page through prompt_results with .range() instead of one un-paginated select, which PostgREST silently capped at 1000 rows — busy brands were aggregating an incomplete fan-out. A 50k-row ceiling bounds the worst case. - classifyFanoutIntents carries AbortSignal.timeout(20s) so a hung aeo-server can never pin the server action until the platform kills it; the tab already degrades to no intent badges on rejection. - The fan-out tab no longer surfaces Next's production-masked digest message ('An error occurred in the Server Components render...') in toasts — masked errors map to friendly copy, real messages still pass through, and the raw error goes to console for debugging.
… the real reason
Confirmed root cause of the reported error: the org was at its
maxPrompts limit, and the PlanLimitError thrown by addPromptToSet
reached production users as Next's masked digest message. Thrown
server-action errors are always masked in production, so trackFanoutQuery
now returns user-facing failures ({ error }) instead of throwing —
plan-limit and no-prompt-set messages survive to the toast verbatim.
Unexpected errors still throw and fall back to the friendly copy.
This was referenced Jul 15, 2026
gkhngyk
added a commit
that referenced
this pull request
Jul 17, 2026
…kground chunks (#448) The Query Fan-out tab requested intent classification for every observed sub-query in a single call. On a cold cache that one request serialized dozens of LLM waves (120 queries ~= 40s+), blew past the server action's 20s fetch timeout (#428), and the badges never arrived that session. Classify progressively instead: the visible page's 10 queries go first (one request, at most ~2 LLM waves), then the remainder in background chunks of 20, each merged into state as it resolves. The table never waits on classification, a failed chunk only leaves its own rows unbadged, and a reload/brand switch cancels the stale chain via a run counter. Already-classified queries are skipped on silent reloads. Closes #431
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
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.
Summary
Fixes #427. Root cause of the reported error is confirmed: the org was at its
maxPromptslimit, and thePlanLimitErrorthrown inside thetrackFanoutQueryserver action reached production users as Next's masked digest message ("An error occurred in the Server Components render…"), surfaced verbatim in a toast.Four fixes, three of them defects found during diagnosis:
trackFanoutQuerynow returns user-facing failures as{ error }instead of throwing — the real message ("Plan limit reached: maximum 200 for maxPrompts. Upgrade to increase.") survives to the toast. Unexpected errors still throw.getQueryFanout/getPromptFanoutpage throughprompt_resultswith.range()(deterministiccreated_at, idorder, 50k-row safety ceiling). PostgREST's un-paginated cap meant busy brands aggregated an incomplete fan-out.classifyFanoutIntentscarriesAbortSignal.timeout(20s)so a slow/hung aeo-server can never pin the server action until the platform kills it; the tab already degrades to no intent badges.Deliberately out of scope: reducing the Track path's sequential DB round-trips (optimization with behavior-change risk; noted in #427).
Related Issue
Fixes #427
Type of Change
How to Test
maxPromptslimit, open Prompts → Query Fan-out and hit + on a sub-query → the toast shows the actual plan-limit message (in production too), not the digest text.prompt_resultsrows in 30 days, the fan-out list includes sub-queries that only appear in rows beyond the first 1000.Checklist
npx tsc --noEmitpassesnpm testpasses (45/45)