Repository navigation
Description
Bug
On the prompts page's Query Fan-out tab (and its two views, frequency / by-prompt), the tab can hang for a long time and then show this raw message in a toast — reproduced in production, also when promoting a sub-query with the Track (+) button:
An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance…
Both views die together because they share one load() path.
What's wrong (multiple compounding defects)
-
Raw digest message reaches the user.
web/src/app/[locale]/(dashboard)/dashboard/prompts/_fanout-tab.tsxcatches the failed server action and doestoast.error(err.message)— in production that message is Next's masked digest text, meaningless to users. It should map to a friendly "couldn't load fan-out" string (and the digest belongs in server logs, not the toast). -
getQueryFanoutscans brand-wide and truncates silently. https://github.com/ansvisor/ansvisor/blob/main/web/src/lib/actions/fanout.ts fetches everyprompt_resultsrow for the brand in the window with the fullsearch_queriesjsonb and aggregates in JS. Two problems:- For busy brands this is slow and can push the server action toward the function time limit — matching the observed "long hang then error".
- Supabase/PostgREST caps un-paginated selects at 1000 rows silently, so the aggregation is quietly incomplete on exactly the brands where fan-out matters most. Fix: paginate with
.range()(or move the aggregation into an RPC like the insights surfaces from perf(insights): aggregate insights data in Postgres instead of pulling rows into Node #114).
-
classifyFanoutIntentsfetch has no timeout. The server action fetches${API_BASE_URL}/api/prompts/fanout-intents, which classifies up to 200 cache-miss queries via LLM at concurrency 6 — minutes on a cold cache. If the express server is slow or hung, the action hangs until the platform kills it. The initial load races it against a 1.5s timeout (good), but the action itself should still carry anAbortControllertimeout (~20s) so it can never pin a function. -
Track (+) path:
trackFanoutQuery→addPromptToSetchains 7+ sequential DB round-trips (set lookup, brand context, org prompt count, plan fetch, topic resolve, shopping-mode read, insert). Worth a look while in here, since the masked error also reproduces on Track.
Diagnosis needed
The Vercel function logs for the failing request contain the real error + digest — attaching that will pinpoint which of (2)/(3)/(4) actually fired in the reported case. The fixes above are worth doing regardless.
Acceptance criteria
- Fan-out tab failures show a human-readable error, never the digest text.
getQueryFanoutaggregates over all rows in the window (no silent 1000-row cap) without approaching function time limits on large brands.classifyFanoutIntentscannot hang indefinitely (bounded fetch timeout, graceful fallback to no intent badges).- Track (+) completes or fails fast with a clear message.
Activity
fix(prompts): consolidate the page's first load into one server action
fix(prompts): consolidate the page's first load into one server action (
feat(prompts): Add prompt dialog on the All Prompts tab (#483)
fix(prompts): surface savePromptSet failures instead of the masked di…
fix(web): return addPromptToSet failures as values instead of throwing (
fix(prompts): aggregate the location quota count in Postgres
feat(prompts): count plan quota by tracked location rather than promp…
feat(prompts): target prompts at multiple countries and US states (#783)
fix(brands): show the brand limit the server enforces, and say so on …
fix(prompts): keep pause/resume failures readable and the quota refre…
feat(prompts): count only active prompt locations toward the plan lim…
feat(prompts): keep per-brand usage counters for the tracked prompts …
feat(prompts): show usage cards above the tracked prompts table (#1054)
fix(chat): answer every failure of Chat's setup actions as a value