fix(extension): resolve 10-item limit truncation & WS zombie disconnection (v0.5.14)

This commit is contained in:
Variet Worker
2026-04-01 18:21:51 +09:00
parent 2d5059d2d5
commit 13f13ee243
10 changed files with 147 additions and 4 deletions

50
test_ws_logic.js Normal file
View File

@@ -0,0 +1,50 @@
// test_ws_logic.js
class FakeWS {
constructor() {
this.msgLog = [];
this.terminated = false;
}
send(msg) {
this.msgLog.push(msg);
}
terminate() {
this.terminated = true;
}
close() {
this.terminated = true;
}
}
// SIMULATE _startHeartbeat() logic from ws-client.ts v0.5.12
function testLogic(isNodeWs, serverSendsPong) {
let ws = new FakeWS();
let connected = true;
let lastPongTime = Date.now();
let forceHeartbeatTimeoutIfNoPong = serverSendsPong;
let checkCounter = 0;
// Fast forward 61 seconds in time
let timeElapsed = 61000;
let currentNow = Date.now() + timeElapsed;
// Simulate heartbeat timeout logic
let conditionMet = false;
if ((isNodeWs || forceHeartbeatTimeoutIfNoPong) && currentNow - lastPongTime > 60000) {
conditionMet = true;
ws.terminate();
}
return {
conditionMet: conditionMet,
terminated: ws.terminated
};
}
console.log("Scenario 1: Node WS (native ping/pong) MUST enforce 60s timeout:");
console.log(testLogic(true, false)); // expect true, true
console.log("\nScenario 2: Browser WS (fallback) + NO JSON PONG FROM SERVER MUST NOT enforce 60s timeout:");
console.log(testLogic(false, false)); // expect false, false (PREVENTS FALSE POSITIVE)
console.log("\nScenario 3: Browser WS (fallback) + JSON PONG FROM SERVER MUST enforce 60s timeout:");
console.log(testLogic(false, true)); // expect true, true (DETECTS ZOMBIE)