mirror of
https://github.com/efiten/coredrive-rx.git
synced 2026-12-04 02:04:08 +00:00
Home becomes a pure monitor and a new Settings tab holds config/diagnostics. - Discover now runs automatically while connected with a 15 s traffic backoff (an overheard 2-byte forwarder/advert means a busy channel — don't poll on top of it); standstill still suspends it. The Flood probe is removed entirely. - New Settings tab: CoreScope broker status + "Push pending now", companion info, diagnostics (verbose, debug log, share/mail the log via Web Share API). - Home enriched: nodes/hex/rx counters, status strip (GPS accuracy, pending, upload health + last-upload age, capture rate), last-reception SNR peak-hold meter, discover status line. - Fix the +60-pending-on-WiFi bug: publish() now times out instead of hanging on a dead socket, drainLoop re-arms in finally so it can never die, MQTT keepalive lowered, and a drain is kicked on broker reconnect / window online. Pure logic in src/monitor.js + src/sharelog.js with tests. SW cache v7→v8. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
// Drain robustness: a publish to a dead socket never acks, so publish() must time
|
|
// out (reject) instead of hanging forever — that hang is what froze the drain loop
|
|
// and left +60 receptions pending on a live WiFi connection.
|
|
// Run: node --test
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert';
|
|
import { Publisher } from '../src/publisher.js';
|
|
|
|
const rec = { rx_at: 't', raw: 'aa', snr: 1, rssi: -90, lat: 0, lon: 0, acc_m: 5 };
|
|
|
|
test('publish rejects when the broker never acks (dead socket)', async () => {
|
|
const p = new Publisher({ url: 'x' });
|
|
p.client = { publish() { /* never invokes the callback — simulates a dead socket */ } };
|
|
await assert.rejects(p.publish('pk', rec, 'name', 50), /publish timeout/);
|
|
});
|
|
|
|
test('publish resolves on a normal ack', async () => {
|
|
const p = new Publisher({ url: 'x' });
|
|
p.client = { publish(_t, _pl, _o, cb) { cb(null); } };
|
|
await assert.doesNotReject(p.publish('pk', rec, 'name', 1000));
|
|
});
|
|
|
|
test('publish rejects on a broker error', async () => {
|
|
const p = new Publisher({ url: 'x' });
|
|
p.client = { publish(_t, _pl, _o, cb) { cb(new Error('nope')); } };
|
|
await assert.rejects(p.publish('pk', rec, 'name', 1000), /nope/);
|
|
});
|