Skip to content

Commit 945efcb

Browse files
committed
clean code
1 parent 7a73ee0 commit 945efcb

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

packages/core-backend/src/AccountActivityService.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -615,27 +615,5 @@ export class AccountActivityService {
615615
'BackendWebSocketService:removeChannelCallback',
616616
`system-notifications.v1.${this.#options.subscriptionNamespace}`,
617617
);
618-
619-
// Unregister action handlers to prevent stale references
620-
this.#messenger.unregisterActionHandler(
621-
'AccountActivityService:subscribeAccounts',
622-
);
623-
this.#messenger.unregisterActionHandler(
624-
'AccountActivityService:unsubscribeAccounts',
625-
);
626-
627-
// Clear our own event subscriptions (events we publish)
628-
this.#messenger.clearEventSubscriptions(
629-
'AccountActivityService:transactionUpdated',
630-
);
631-
this.#messenger.clearEventSubscriptions(
632-
'AccountActivityService:balanceUpdated',
633-
);
634-
this.#messenger.clearEventSubscriptions(
635-
'AccountActivityService:subscriptionError',
636-
);
637-
this.#messenger.clearEventSubscriptions(
638-
'AccountActivityService:statusChanged',
639-
);
640618
}
641619
}

packages/core-backend/src/BackendWebSocketService.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,14 +630,18 @@ describe('BackendWebSocketService', () => {
630630
mockWs.simulateClose(1000, 'Normal closure');
631631
await completeAsyncOperations(0);
632632

633-
// Service should be in ERROR state (non-recoverable)
634-
expect(service.getConnectionInfo().state).toBe(WebSocketState.ERROR);
633+
// Service should be in DISCONNECTED state (normal closure, not an error)
634+
expect(service.getConnectionInfo().state).toBe(
635+
WebSocketState.DISCONNECTED,
636+
);
635637

636638
// Advance time - should NOT attempt reconnection
637639
await completeAsyncOperations(200);
638640

639-
// Should still be in ERROR state
640-
expect(service.getConnectionInfo().state).toBe(WebSocketState.ERROR);
641+
// Should still be in DISCONNECTED state (no reconnection for normal closures)
642+
expect(service.getConnectionInfo().state).toBe(
643+
WebSocketState.DISCONNECTED,
644+
);
641645
},
642646
);
643647
});

packages/core-backend/src/BackendWebSocketService.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,12 +1086,10 @@ export class BackendWebSocketService {
10861086
const shouldReconnect = this.#shouldReconnectOnClose(event.code);
10871087

10881088
if (shouldReconnect) {
1089-
log('Connection lost unexpectedly, will attempt reconnection');
1089+
log('Connection lost unexpectedly, will attempt reconnection', {
1090+
code: event.code,
1091+
});
10901092
this.#scheduleReconnect();
1091-
} else {
1092-
// Non-recoverable error - set error state
1093-
log('Non-recoverable error', { code: event.code });
1094-
this.#setState(WebSocketState.ERROR);
10951093
}
10961094
}
10971095

0 commit comments

Comments
 (0)