Skip to content

Commit 40661ca

Browse files
author
Ravi Singh
committed
fix: WebSocket /api/live silently dropped + atoms.tsx missing useRef/useEffect imports
Two compounding bugs from the previous comprehensive rewrite that together produced "distance shows 0 + console useRef error": 1. Server-side route table overflow. esp_http_server cfg.max_uri_handlers was 32. The previous PRs added /api/mesh GET/POST, /api/topology GET/POST, /api/factory_reset, /api/ping, /api/system GET/POST, /api/radar/diag — bringing total route count to 33. The WS route is registered last, so it silently failed registration. No client could subscribe to live data, so the Live screen distance stayed at 0 forever. Bumped to 48. Verified post-flash: WS handshake returns 101 Switching Protocols from python ws client; chunked HTML still serves intact at 81 KB. 2. Client-side missing imports. atoms.tsx uses useRef (in DualHandleRange) and useEffect (in DualHandleRange + LineChart) but only imported useState from preact/hooks. Errors only fired on LEDs/Motion tabs where those components render. Added the missing imports. Build: same 1.16 MB, both C3s flashed, all 11 endpoints verified live.
1 parent 5d6419a commit 40661ca

4 files changed

Lines changed: 3 additions & 3 deletions

File tree

firmware/components/webui/ui.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
-13 Bytes
Binary file not shown.

firmware/components/webui/webui.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ esp_err_t webui_init(void) {
10771077

10781078
httpd_config_t cfg = HTTPD_DEFAULT_CONFIG();
10791079
cfg.lru_purge_enable = true;
1080-
cfg.max_uri_handlers = 32;
1080+
cfg.max_uri_handlers = 48; /* was 32 — overflowed at 33 once mesh/topology/factory_reset/ping/system routes were added; the /api/live WS handler stopped registering and the dashboard could no longer get live data */
10811081
cfg.max_open_sockets = 7;
10821082
cfg.stack_size = 8192;
10831083
cfg.recv_wait_timeout = 10;

frontend/src/atoms.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* handoff (frontend/design-source/project/core.jsx). Kept in their own
33
* file so they're easy to lift verbatim. */
44
import { JSX } from 'preact';
5-
import { useState } from 'preact/hooks';
5+
import { useState, useEffect, useRef } from 'preact/hooks';
66

77
export const Icon = ({ name, size = 16, stroke = 1.6, style }: {
88
name: string; size?: number; stroke?: number; style?: any;

0 commit comments

Comments
 (0)