mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
fix(satellites): forget ISS telemetry from dropped sockets
A new ISSLive connection must rebuild its own joint snapshot and station-clock liveness. Without clearing the prior session, a fast reconnect can mark old joint positions live before fresh angles arrive. Add a node:test reconnect regression and update the runtime contract. Follow-up to PR #1767 by ZloyS; original ISS model credit: IMBrandao (#1690). Tests: node --test server/providers/space/issTelemetry.test.mjs (UNRUN)
This commit is contained in:
1 parent
f0d2906220
commit
79ab830824
4 files changed
+55
-1
No files matched your search
@@ -179,6 +179,11 @@ export function createIssTelemetryRelay({ createSocket, now = Date.now }) {
|
||||
const old = socket;
|
||||
socket = null;
|
||||
fields.clear();
|
||||
// A replacement session must rebuild both its joint snapshot and signal
|
||||
// credit; a new clock tick cannot make the old session's angles live.
|
||||
values.clear();
|
||||
signalAt = null;
|
||||
signalClass = null;
|
||||
try {
|
||||
old?.terminate?.();
|
||||
} catch {
|
||||
|
||||
@@ -219,6 +219,49 @@ test('a lost or silent connection is retried on a ladder, and stale events are i
|
||||
assert.equal(third.terminated, true);
|
||||
});
|
||||
|
||||
test('a reconnect cannot mark the previous socket\'s joint samples live', () => {
|
||||
const { relay, sockets, clock } = relayAt(NOV_13);
|
||||
relay.demand();
|
||||
const first = sockets[0];
|
||||
first.emit('open');
|
||||
first.emit('message', 'CONOK,S1,50000,5000,*');
|
||||
const stamp = stampOf(clock.ms);
|
||||
first.emit(
|
||||
'message',
|
||||
`U,1,${index('S0000004')},${stamp}|17|24\r\n` +
|
||||
`U,1,${index('TIME_000001')},${stamp}|1|24`,
|
||||
);
|
||||
assert.equal(relay.snapshot().status, 'live');
|
||||
assert.deepEqual(relay.snapshot().items.S0000004, [17, clock.ms]);
|
||||
|
||||
first.emit('close');
|
||||
assert.equal(relay.snapshot().status, 'reconnecting');
|
||||
clock.ms += 5_000;
|
||||
relay.demand();
|
||||
assert.equal(sockets.length, 2);
|
||||
assert.equal(relay.snapshot().status, 'connecting');
|
||||
assert.deepEqual(relay.snapshot().items, {});
|
||||
|
||||
const second = sockets[1];
|
||||
second.emit('open');
|
||||
second.emit('message', 'CONOK,S2,50000,5000,*');
|
||||
// The clock can return before any new joint snapshot is delivered.
|
||||
second.emit(
|
||||
'message',
|
||||
`U,1,${index('TIME_000001')},${stampOf(clock.ms)}|1|24`,
|
||||
);
|
||||
assert.equal(relay.snapshot().status, 'live');
|
||||
assert.deepEqual(
|
||||
relay.snapshot().items,
|
||||
{},
|
||||
'the new clock must not revive old joint angles',
|
||||
);
|
||||
second.emit(
|
||||
'message',
|
||||
`U,1,${index('S0000004')},${stampOf(clock.ms)}|23|24`,
|
||||
);
|
||||
assert.deepEqual(relay.snapshot().items.S0000004, [23, clock.ms]);
|
||||
});
|
||||
test('a refused or ended session starts over', () => {
|
||||
for (const line of ['CONERR,2,x', 'END,31,x', 'LOOP,0', 'REQERR,1,17,x']) {
|
||||
const { relay, sockets } = relayAt(NOV_13);
|
||||
|
||||
Reference in new issue
Block a user