Trade pair click-switch crashes to ErrorBoundary: workspace prefetch seeds a flat page into the infinite limit-book query key #354
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#354
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Clicking a different pair in the /trade pair search reliably crashes the whole trade view to the app ErrorBoundary ("Something went wrong") once the workspace prefetch resolves. The selector and navigation themselves work — the crash is in the order-book panel render that follows the switch.
Mechanism (source + console-stack layer)
onPairChange(TradePage.tsx:314) callsprefetchTradePairWorkspaceBEFORE navigate; tradePairPrefetch.ts:33-43 prefetches the limit book withqueryClient.prefetchQueryunder['limitBookPage', pair, side]— storing the FLATIndexerLimitBookPageResponse { side, orders, has_more, next_after_order_id }.useLimitBookInfinite(useLimitBookInfinite.ts:10-11) consumes the SAME key asuseInfiniteQuery, which requiresInfiniteData { pages, pageParams }.BookSideColumn(OrderBookPanel.tsx:221) renders within the shared 10s staleTime, TanStack v5's internal getNextPageParam wrapper destructurespagesfrom the flat object andpages.lengththrows (infiniteQueryBehavior.ts:136) — synchronously during render, so theq.isErrorguard and theq.data?.pagesoptional chain never run; it unwinds to the app-level ErrorBoundary.fetchJsonthrows on non-OK (client.ts:44-46), so an HTTP error on the book request actually AVOIDS the crash — it needs the prefetch to succeed. (We also hit real indexer 429s in the same session; filing that separately — co-symptom, not the cause.)67c0ea2(#180) added the flat prefetch against the already-infinite consumer key;23ffb21(#194) extracted the hook and kept the collision. CI stays green because tradePairPrefetch.test only asserts the fetchers fire, and the useLimitBookInfinite tests never mount the hook against a prefetch-seeded cache.Repro
TypeError: Cannot read properties of undefined (reading 'length') at getNextPageParam ... at useLimitBookInfinite (useLimitBookInfinite.ts:10) at BookSideColumn (OrderBookPanel.tsx:221).Fix direction
queryClient.prefetchInfiniteQuery(initialPageParam undefined, single page) so the seeded entry is{ pages, pageParams }.Relation to #350
Likely the missing piece of what totdking hit on VP-4: selection commits, then the workspace fails. The type+Enter default-revert documented on #350 is still a separate, additional defect in the same control.
Severity: blocker-class for trade UX — pair switching by click cannot complete.
cc @PlasticDigits
mentioned in issue #350
mentioned in issue #337
mentioned in commit
35e38e54b2mentioned in merge request !851
Implementation
MR: !851 (
local1/354-impl-prefetch-infinite)prefetchTradePairWorkspacenow usesprefetchInfiniteQueryfor limit-book pages so the seeded cache shape matchesuseLimitBookInfinite. Added regression tests and documented the invariant in skills/docs.Verification checklist
/trade, click a different pair in the pair search — no ErrorBoundary crashmake test-frontend—tradePairPrefetch*.test*anduseLimitBookInfinite.test.tsxpassFollow-ups
None — click-switch path for #350 depends on this landing first.
mentioned in commit
76072064a0Verified the merged fix (!851, commit
35e38e5) at source + unit-test layer one198dcb. tradePairPrefetch now uses prefetchInfiniteQuery with the same initialPageParam/getNextPageParam shape as useLimitBookInfinite, so the shared ['limitBookPage',pair,side] key is seeded as proper InfiniteData {pages,pageParams} instead of a flat page — the consumer no longer reads pages.length off a flat object during render. Proved it: the two new regression tests pass on HEAD and FAIL 2/2 against the pre-fix source (checked out at35e38e5^ in a worktree) — exactly the crash path. Live click-switch browser re-test is the laptop layer, in progress.mentioned in issue #357
mentioned in merge request !863