fix: add null guards to prevent runtime crashes

- popup.js: guard peers/state.acks in updateLastActionUI()
- popup.js: guard state.duration in refreshDebugInfo()
- popup.js: guard elements.lobbyPeerStatus in updateLobbyUI()
- background.js: use Array.isArray() for currentRoom.peers.length checks
This commit is contained in:
Koala
2026-05-25 09:57:01 +02:00
parent 4909a86a13
commit c9f93dc4ba
2 changed files with 13 additions and 10 deletions
+3 -3
View File
@@ -577,7 +577,7 @@ function handleServerEvent(event, data) {
}
// Check if all peers responded
const peerCount = currentRoom ? currentRoom.peers.length : 1;
const peerCount = currentRoom && Array.isArray(currentRoom.peers) ? currentRoom.peers.length : 1;
if (forceSyncAcks.size >= peerCount) {
executeForceSync();
}
@@ -649,7 +649,7 @@ function handleServerEvent(event, data) {
}
if (isForceSyncInitiator) {
const peerCount = currentRoom.peers ? currentRoom.peers.length : 1;
const peerCount = Array.isArray(currentRoom.peers) ? currentRoom.peers.length : 1;
if (forceSyncAcks.size >= peerCount) {
executeForceSync();
}
@@ -1179,7 +1179,7 @@ async function handleAsyncMessage(message, sender, sendResponse) {
});
}
const peerCount = currentRoom ? currentRoom.peers.length : 1;
const peerCount = currentRoom && Array.isArray(currentRoom.peers) ? currentRoom.peers.length : 1;
if (forceSyncAcks.size >= peerCount) {
executeForceSync();
}