cultnet-ts test: cancel the Odin stub's delayed send when the test ends
Some checks failed
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Failing after 7m47s
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Successful in 57s
Some checks failed
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Failing after 7m47s
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Successful in 57s
The stub's 120 ms second packet fired after peer.close() and threw ERR_SOCKET_DGRAM_NOT_RUNNING as an uncaught exception, failing whichever publisher test was running when the timer landed (load-dependent). Timers are now cleared in the test's after hook instead of swallowing the error. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0b326fa5ee
commit
531fce567d
1 changed files with 6 additions and 3 deletions
|
|
@ -276,7 +276,10 @@ async function startOdinPeer(context: TestContext, endpoint: string) {
|
|||
peer.once("error", reject);
|
||||
peer.bind(port, "127.0.0.1", resolve);
|
||||
});
|
||||
context.after(() => peer.close());
|
||||
// The second packet of a split delivery is a timer; the test's end cancels it rather than racing the closed socket.
|
||||
const timers = new Set<NodeJS.Timeout>();
|
||||
const later = (send: () => void) => { timers.add(setTimeout(send, 120)); };
|
||||
context.after(() => { for (const timer of timers) clearTimeout(timer); peer.close(); });
|
||||
const state = {
|
||||
reject: false,
|
||||
// How a refusal and the ack of the put reach the publisher: in one packet, or the ack first, or the refusal first.
|
||||
|
|
@ -309,10 +312,10 @@ async function startOdinPeer(context: TestContext, endpoint: string) {
|
|||
state.responseAck = response.ack;
|
||||
if (state.reject && state.order === "ack-then-refusal") {
|
||||
peer.send(encodeRudpPacket(serverSession.createAckForReceived(packet.sequence)), remote.port, remote.address);
|
||||
setTimeout(() => { try { peer.send(encodeRudpPacket(response), remote.port, remote.address); } catch { /* the test ended */ } }, 120);
|
||||
later(() => peer.send(encodeRudpPacket(response), remote.port, remote.address));
|
||||
} else if (state.reject && state.order === "refusal-then-ack") {
|
||||
peer.send(encodeRudpPacket({ ...response, ack: 0, ackMask: 0 }), remote.port, remote.address);
|
||||
setTimeout(() => { try { peer.send(encodeRudpPacket(serverSession!.createAckForReceived(packet.sequence)), remote.port, remote.address); } catch { /* the test ended */ } }, 120);
|
||||
later(() => peer.send(encodeRudpPacket(serverSession!.createAckForReceived(packet.sequence)), remote.port, remote.address));
|
||||
} else {
|
||||
peer.send(encodeRudpPacket(response), remote.port, remote.address);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue