fix(perf): polling-only Socket.IO + channels DB fallback on USB timeout

Werkzeug dev server can't upgrade WebSockets, so every io() upgrade attempt
returned HTTP 500 and clients fell into a polling/upgrade reconnect loop —
visible as 10-15s freezes on app load. Force transports: ['polling'] on
/chat, /console and /logs clients; long-poll keeps real-time pushes
working with ~1-2s latency.

When the MeshCore device briefly stalls, get_channel_info() used to block
on the default 30s timeout per slot, so iterating max_channels slots could
take minutes; in practice only Public answered and the rest timed out,
leaving the UI with just one channel. Drop per-call timeout to 3s, raise
TimeoutError to the caller, and have cli.get_channels() break on first
timeout and merge the remaining slots from the channels table in the DB
(which already mirrors device state via upsert_channel).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-06-07 07:31:47 +02:00
parent f34c95c15b
commit 1d47c9c0e8
6 changed files with 70 additions and 9 deletions
+2 -1
View File
@@ -403,7 +403,8 @@ function connectChatSocket() {
const wsUrl = window.location.origin;
chatSocket = io(wsUrl + '/chat', {
transports: ['websocket', 'polling'],
transports: ['polling'],
upgrade: false,
reconnection: true,
reconnectionDelay: 2000,
reconnectionDelayMax: 10000,
+2 -1
View File
@@ -38,7 +38,8 @@ function connectWebSocket() {
try {
socket = io(wsUrl + '/console', {
transports: ['websocket', 'polling'],
transports: ['polling'],
upgrade: false,
reconnection: true,
reconnectionAttempts: Infinity,
reconnectionDelay: 1000,
+2 -1
View File
@@ -125,7 +125,8 @@ function connectChatSocket() {
const wsUrl = window.location.origin;
chatSocket = io(wsUrl + '/chat', {
transports: ['websocket', 'polling'],
transports: ['polling'],
upgrade: false,
reconnection: true,
reconnectionDelay: 2000,
reconnectionDelayMax: 10000,
+2 -1
View File
@@ -33,7 +33,8 @@
// --- WebSocket ---
const socket = io('/logs', {
transports: ['websocket', 'polling'],
transports: ['polling'],
upgrade: false,
reconnection: true,
reconnectionDelay: 2000,
});