Limits page crashes with Cannot read properties of undefined (reading 'length') for most pairs on fresh deploy #327
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#327
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
On a fresh deploy (
make reset-qa/make deploy-local) with the indexer running (make indexer-dev), navigating to the Limits page and switching between pairs crashes most of them withCannot read properties of undefined (reading 'length')rendered directly on screen. Only EMBER/CORAL loaded correctly during the observed session. The issue resolved on its own during the same session — likely after the indexer finished its initial sync.The error implies a
.lengthread on a value that wasundefinedat render time, reaching the screen rather than being caught by an error boundary that shows a graceful message.Root cause (suspected, unconfirmed — requires developer investigation)
Two code paths are the most likely candidates based on static analysis:
Candidate 1 —
getAllPairsPaginatedinfactory.ts:44:getAllPairscallsqueryContract, which returnsdata.data as Tfrom the LCD response. If the LCD node or the factory contract returns a response wherepairsis absent (e.g. during initial startup before contract state is ready),resp.pairsisundefinedandresp.pairs.lengthcrashes with exactly "Cannot read properties of undefined (reading 'length')".This runs inside a
useQuery queryFn, so React Query catches it and stores it aspairsQuery.isError = true. Whether the error then propagates to a rendered crash depends on how upstream code handlespairsQuery.isError— if no graceful error state is shown for that case, the component tree may crash.Candidate 2 — indexer
/limit-bookreturning a response withoutordersfor unsynced pairs:useLimitBookInfinitecallsgetPairLimitBookPage, which expectsIndexerLimitBookPageResponse: { orders: IndexerShallowLimitOrder[], has_more, ... }. If the indexer returns a page without theordersfield for a pair it hasn't fully indexed yet,p.ordersisundefined. TheOrderBookPanelderivesordersvia:When
p.ordersisundefined,flatMapreturns[undefined](the?? []fallback doesn't trigger because the result is a non-null array). Downstream rendering ofBookRowthen accessesorder.owner,order.order_id,order.price, etc. on theundefineditem, crashing at the first unguarded property read. The specific.lengtherror may arise in a string operation on one of these fields.Why EMBER/CORAL works: EMBER/CORAL is the first pair deployed and likely the first pair fully indexed by the indexer. Pairs deployed after it may not yet have their
limit-bookentries populated when the frontend first queries them.Steps to reproduce
make reset-qaormake deploy-localto get a fresh deploymake indexer-devmake dev/limits)Cannot read properties of undefined (reading 'length')directly on screenExpected behavior
All pairs should either:
No raw JavaScript error message should be rendered to the user under any conditions. An error boundary or per-component fallback should intercept the crash and show a user-friendly message.
Actual behavior
Raw JS crash:
Cannot read properties of undefined (reading 'length')is displayed directly on screen for most pairs immediately after a fresh deploy. The error is transient — it self-resolves after the indexer finishes syncing. No actionable message is shown to the user.Additional notes
pairsquery (Candidate 1) or the indexerlimit-bookquery (Candidate 2)console.logingetAllPairsPaginatedandgetPairLimitBookPageon a fresh deploy to capture the raw response before the crashEnvironment
make reset-qa/make deploy-local/limitsmake indexer-dev), initial sync in progress at time of crashSeverity: P2(polish) not a permanent breakage, but reproducible on every fresh deploy and exposes a raw JS crash to the user with no error message or fallback. Needs root cause confirmation before a fix can be scoped.
cc: @PlasticDigits
Related checklist items: EH-2, EH-3
mentioned in commit
499e642c5amentioned in commit
c09b71a0e4mentioned in merge request !803
Implementation (agent:implement)
MR: https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/85
Confirmed root cause: missing
orderson limit-book pages madeflatMap((p) => p.orders)produce[undefined], which crashed render/hint code (often surfacing asCannot read properties of undefined (reading 'length')via the error boundary). Secondary guard added for missingpairsin factory pagination.Acceptance
OrderBookPanel,LimitOrdersPage, client normalization)orders)normalizeLimitBookPageResponse+flattenLimitBookPagestestspairsquery robustnessfactory.test.tsmissingpairspagehumanizeUserFacingError.test.tsBlocker for closing: manual fresh-deploy verification on MR merge (issue steps 1–10).
mentioned in commit
9d97e98108