"Cannot read properties of null (reading 'useContext')" crash triggered from Trader Profile tab with Station wallet connected #126

Closed
opened 2026-05-04 15:42:05 +00:00 by totdking · 11 comments
totdking commented 2026-05-04 15:42:05 +00:00 (Migrated from gitlab.com)
No description provided.
totdking commented 2026-05-04 16:18:52 +00:00 (Migrated from gitlab.com)

Issue Summary

After connecting a Station wallet and navigating to the Trader Profile tab, the entire page crashes with a full screen error overlay displaying "SOMETHING WENT WRONG" and the message Cannot read properties of null (reading 'useContext'). Clicking any other navigation tab (Swap, Pool, Limits, Trade, Charts) while the error is displayed does not recover the page. A manual browser refresh resolves the issue.


Reproduction Steps

  1. Start LocalTerra, deploy contracts (make deploy-local), run the indexer (make indexer-dev), and start the frontend (VITE_NETWORK=local npm run dev)
  2. Open the app at http://localhost:5173 in Chrome
  3. Navigate around the app for a few minutes without a wallet connected
  4. Connect a Station wallet configured for the local network (localterra, LCD http://localhost:1317, RPC http://localhost:26657)
  5. Click the Trader Profile tab in the navigation
  6. Observe the crash, the full-screen error overlay appears
  7. Attempt to click other tabs (Swap, Pool, Limits, Trade, Charts) — all remain broken
  8. Refresh the page, the app recovers normally

Expected Behavior

Clicking the Trader Profile tab after wallet connection should render the Trader Profile page without errors. Navigation to other tabs should remain functional at all times.


Actual Behavior

The app crashes with a full-screen error overlay:

SOMETHING WENT WRONG
Cannot read properties of null (reading 'useContext')

All navigation tabs become non-functional until the page is manually refreshed. The "TRY AGAIN" button is shown but a full refresh is required to restore the app.


Environment Details

Field Value
OS macOS (Apple M1 Pro, 14-inch)
Browser Google Chrome (desktop)
Network localterra (local Docker)
Frontend VITE_NETWORK=local npm run dev
Indexer Running (make indexer-dev)
Contracts Deployed via make deploy-local
Setup stage Step 7 (Wallets: exploratory testing)

Wallet / Device Details

  • Wallet: Station browser extension
  • Network configured in Station: localterra: LCD http://localhost:1317, RPC http://localhost:26657
  • Connection timing: Wallet connected after several minutes of unauthenticated navigation

Screenshots

See attached screenshot showing the full-screen "SOMETHING WENT WRONG" error with the message Cannot read properties of null (reading 'useContext') and the "TRY AGAIN" button. Navigation tabs (Swap, Pool, Limits, Trade, Charts) are visible but non-functional in this state.

telegram-cloud-photo-size-4-6037252210653073507-y.jpg{width="900" height="545"}


Console Logs

Console was not captured at the time of occurrence. Will record DevTools console output on next reproduction attempt.


Severity / Impact

Since bug is not reproducible at will, no severity is assigned.

### Issue Summary After connecting a Station wallet and navigating to the Trader Profile tab, the entire page crashes with a full screen error overlay displaying "SOMETHING WENT WRONG" and the message `Cannot read properties of null (reading 'useContext')`. Clicking any other navigation tab (Swap, Pool, Limits, Trade, Charts) while the error is displayed does not recover the page. A manual browser refresh resolves the issue. --- ### Reproduction Steps 1. Start LocalTerra, deploy contracts (`make deploy-local`), run the indexer (`make indexer-dev`), and start the frontend (`VITE_NETWORK=local npm run dev`) 2. Open the app at `http://localhost:5173` in Chrome 3. Navigate around the app for a few minutes without a wallet connected 4. Connect a Station wallet configured for the local network (`localterra`, LCD `http://localhost:1317`, RPC `http://localhost:26657`) 5. Click the **Trader Profile** tab in the navigation 6. Observe the crash, the full-screen error overlay appears 7. Attempt to click other tabs (Swap, Pool, Limits, Trade, Charts) — all remain broken 8. Refresh the page, the app recovers normally --- ### Expected Behavior Clicking the Trader Profile tab after wallet connection should render the Trader Profile page without errors. Navigation to other tabs should remain functional at all times. --- ### Actual Behavior The app crashes with a full-screen error overlay: ``` SOMETHING WENT WRONG Cannot read properties of null (reading 'useContext') ``` All navigation tabs become non-functional until the page is manually refreshed. The "TRY AGAIN" button is shown but a full refresh is required to restore the app. --- ### Environment Details | Field | Value | |-------|-------| | OS | macOS (Apple M1 Pro, 14-inch) | | Browser | Google Chrome (desktop) | | Network | `localterra` (local Docker) | | Frontend | `VITE_NETWORK=local npm run dev` | | Indexer | Running (`make indexer-dev`) | | Contracts | Deployed via `make deploy-local` | | Setup stage | Step 7 (Wallets: exploratory testing) | --- ### Wallet / Device Details - **Wallet:** Station browser extension - **Network configured in Station:** localterra: LCD `http://localhost:1317`, RPC `http://localhost:26657` - **Connection timing:** Wallet connected after several minutes of unauthenticated navigation --- ### Screenshots > See attached screenshot showing the full-screen "SOMETHING WENT WRONG" error with the message `Cannot read properties of null (reading 'useContext')` and the "TRY AGAIN" button. Navigation tabs (Swap, Pool, Limits, Trade, Charts) are visible but non-functional in this state. ![telegram-cloud-photo-size-4-6037252210653073507-y.jpg](/uploads/3a3c3fb8d1aed0cb70d1420bf9f3bd40/telegram-cloud-photo-size-4-6037252210653073507-y.jpg){width="900" height="545"} --- ### Console Logs Console was not captured at the time of occurrence. Will record DevTools console output on next reproduction attempt. --- ### Severity / Impact **Since bug is not reproducible at will, no severity is assigned.**
Brouie commented 2026-05-05 23:55:34 +00:00 (Migrated from gitlab.com)

mentioned in issue #133

mentioned in issue #133
PlasticDigits commented 2026-05-06 09:35:19 +00:00 (Migrated from gitlab.com)

mentioned in commit 8a8b49ab44

mentioned in commit 8a8b49ab44d1ea3c7469431acd55eb12fc386187
PlasticDigits commented 2026-05-06 09:35:54 +00:00 (Migrated from gitlab.com)

Update (fix merged to main)

Implemented hardening for the Trader Profile route after investigation of the useContext / full-screen error report (8a8b49a).

What changed

  • Strict indexer JSON parsing for GET /api/v1/traders/:address via parseIndexerTraderPayload so null, arrays, or partial objects never become a truthy trader object that could throw during render (frontend-dapp/src/services/indexer/traderProfilePayload.ts, wired from getTrader in client.ts).
  • Route error boundary resetKeys tied to :address so moving between /trader, /trader/<addr>, or another address clears a prior route error without a full reload (TraderRouteShell in App.tsx).
  • Vite resolve.dedupe for react / react-dom to reduce rare dual-React dev/bundle issues that surface as invalid hook / useContext errors when lazy chunks load.
  • TraderPage imports StatBox / TradesTable / RetryError / Skeleton from their modules (smaller lazy chunk, less barrel surface).
  • Docs: docs/frontend.md § Trader profile (indexer JSON + route error recovery). Skills crosslinks: skills/AGENTS_BUNDLE_DEV_WALLET.md, skills/AGENTS_LOCALNET_TRADING_SWARM.md.
  • Tests: frontend-dapp/src/services/indexer/traderProfilePayload.test.ts (Vitest). Full npm run test:unit and npm run build were run successfully on the branch before merge.

Checklist for verification (@totdking)

  • Local stack: indexer + VITE_NETWORK=local npm run dev (per issue repro).
  • Connect Station for LocalTerra; open More → Trader and wallet menu → Trader profile (/trader and /trader/<you>).
  • Confirm no full-screen Something went wrong / useContext overlay; indexer-offline paths still show the existing indexer warning / retry UI.
  • If you can still trigger a route-level error, navigate Swap → Trader → Swap (or change /trader/<addr>) and confirm the UI recovers without a hard refresh (resetKeys).
  • Optional: DevTools Network → GET .../api/v1/traders/<addr> returns JSON object with address; malformed proxy responses should surface as query error (“Trader not found” / retry), not a white-screen hook crash.

Please verify on your side when you have a moment — leaving the issue open until you confirm.

cc @totdking

## Update (fix merged to `main`) Implemented hardening for the Trader Profile route after investigation of the `useContext` / full-screen error report ([`8a8b49a`](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/commit/8a8b49a)). ### What changed - **Strict indexer JSON parsing** for `GET /api/v1/traders/:address` via `parseIndexerTraderPayload` so `null`, arrays, or partial objects never become a truthy `trader` object that could throw during render (`frontend-dapp/src/services/indexer/traderProfilePayload.ts`, wired from `getTrader` in `client.ts`). - **Route error boundary `resetKeys`** tied to `:address` so moving between `/trader`, `/trader/<addr>`, or another address clears a prior route error without a full reload (`TraderRouteShell` in `App.tsx`). - **Vite `resolve.dedupe`** for `react` / `react-dom` to reduce rare dual-React dev/bundle issues that surface as invalid hook / `useContext` errors when lazy chunks load. - **TraderPage** imports `StatBox` / `TradesTable` / `RetryError` / `Skeleton` from their modules (smaller lazy chunk, less barrel surface). - **Docs:** `docs/frontend.md` § [Trader profile (indexer JSON + route error recovery)](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/blob/main/docs/frontend.md#trader-profile-indexer). **Skills crosslinks:** `skills/AGENTS_BUNDLE_DEV_WALLET.md`, `skills/AGENTS_LOCALNET_TRADING_SWARM.md`. - **Tests:** `frontend-dapp/src/services/indexer/traderProfilePayload.test.ts` (Vitest). Full `npm run test:unit` and `npm run build` were run successfully on the branch before merge. ### Checklist for verification (@totdking) - [ ] Local stack: indexer + `VITE_NETWORK=local npm run dev` (per issue repro). - [ ] Connect **Station** for LocalTerra; open **More → Trader** and **wallet menu → Trader profile** (`/trader` and `/trader/<you>`). - [ ] Confirm **no** full-screen `Something went wrong` / `useContext` overlay; indexer-offline paths still show the existing indexer warning / retry UI. - [ ] If you can still trigger a route-level error, navigate **Swap → Trader → Swap** (or change `/trader/<addr>`) and confirm the UI **recovers without** a hard refresh (resetKeys). - [ ] Optional: DevTools **Network** → `GET .../api/v1/traders/<addr>` returns JSON object with `address`; malformed proxy responses should surface as **query error** (“Trader not found” / retry), not a white-screen hook crash. Please verify on your side when you have a moment — leaving the issue **open** until you confirm. cc @totdking
totdking commented 2026-05-06 12:47:50 +00:00 (Migrated from gitlab.com)

Checklist for verification (@totdking)

  • Local stack: indexer + VITE_NETWORK=local npm run dev (per issue repro).
  • Connect Station for LocalTerra; open More → Trader and wallet menu → Trader profile (/trader and /trader/<you>).
  • Confirm no full-screen Something went wrong / useContext overlay; indexer-offline paths still show the existing indexer warning / retry UI.
  • If you can still trigger a route-level error, navigate Swap → Trader → Swap (or change /trader/<addr>) and confirm the UI recovers without a hard refresh (resetKeys). - COULD NOT TRIGGER THE ROUTE-LEVEL ERROR
  • Optional: DevTools Network → GET .../api/v1/traders/<addr> returns JSON object with address; malformed proxy responses should surface as query error (“Trader not found” / retry), not a white-screen hook crash.

Visual checklist verification for crash triggered on "trader's profile" tab

  • Observed
  • Environment details:
Field Value
OS macOS (Apple M1 Pro, 14-inch)
Browser Google Chrome (desktop)
Network localterra (local Docker)
Frontend VITE_NETWORK=local npm run dev
Indexer Running (make indexer-dev)
Contracts Deployed via make deploy-local
wallet Station Wallet & Keplr wallet
Viewport 1470×864

**Ready for close on dev side** : true

cc: @PlasticDigits

### Checklist for verification (@totdking) * [x] Local stack: indexer + `VITE_NETWORK=local npm run dev` (per issue repro). * [x] Connect **Station** for LocalTerra; open **More → Trader** and **wallet menu → Trader profile** (`/trader` and `/trader/<you>`). * [x] Confirm **no** full-screen `Something went wrong` / `useContext` overlay; indexer-offline paths still show the existing indexer warning / retry UI. * [ ] If you can still trigger a route-level error, navigate **Swap → Trader → Swap** (or change `/trader/<addr>`) and confirm the UI **recovers without** a hard refresh (resetKeys). - **COULD NOT TRIGGER THE ROUTE-LEVEL ERROR** * [x] Optional: DevTools **Network** → `GET .../api/v1/traders/<addr>` returns JSON object with `address`; malformed proxy responses should surface as **query error** (“Trader not found” / retry), not a white-screen hook crash. ### Visual checklist verification for crash triggered on "trader's profile" tab * Observed * Environment details: | Field | Value | |-------|-------| | OS | macOS (Apple M1 Pro, 14-inch) | | Browser | Google Chrome (desktop) | | Network | `localterra` (local Docker) | | Frontend | `VITE_NETWORK=local npm run dev` | | Indexer | Running (`make indexer-dev`) | | Contracts | Deployed via `make deploy-local` | | wallet | Station Wallet & Keplr wallet | | Viewport | 1470×864 | \*\*Ready for close on dev side\*\* : true cc: @PlasticDigits
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-05-06 12:59:06 +00:00
PlasticDigits commented 2026-05-06 12:59:07 +00:00 (Migrated from gitlab.com)

Closing, keep an eye out for the route level error if it reemerges please link this issue

Closing, keep an eye out for the route level error if it reemerges please link this issue
PlasticDigits commented 2026-08-26 03:07:39 +00:00 (Migrated from gitlab.com)

mentioned in issue #656

mentioned in issue #656
PlasticDigits commented 2026-08-26 03:08:07 +00:00 (Migrated from gitlab.com)

mentioned in issue #657

mentioned in issue #657
PlasticDigits commented 2026-08-26 03:08:08 +00:00 (Migrated from gitlab.com)

marked as related to #657

marked as related to #657
PlasticDigits commented 2026-08-26 04:16:12 +00:00 (Migrated from gitlab.com)

mentioned in issue #665

mentioned in issue #665
PlasticDigits commented 2026-08-30 02:48:10 +00:00 (Migrated from gitlab.com)

mentioned in issue #706

mentioned in issue #706
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#126
No description provided.