Say what a peer did with each receipt segment, and leave no drop unlogged

This commit is contained in:
2026-09-01 17:59:37 +02:00
parent 67c0402def
commit 61985fb914
7 changed files with 113 additions and 36 deletions
+16 -6
View File
@@ -21,6 +21,7 @@ export class HeldMessages {
private readonly held: ExpiringGroups<PduObject[]>;
private readonly idleWaiters = new IdleWaiters();
private readonly log: SmppLog;
private readonly max: number;
constructor(options: HeldMessagesOptions) {
this.held = new ExpiringGroups({
@@ -29,6 +30,7 @@ export class HeldMessages {
timeout: options.timeout,
});
this.log = options.log;
this.max = options.max;
}
/** An application that answers no message at all may not grow this without end. */
@@ -37,12 +39,10 @@ export class HeldMessages {
if (key === undefined) return;
if (this.held.full) {
const evicted = this.held.takeOldest();
if (evicted) {
this.log.warn('heldMessages - dropping the message held longest', { seqNr: evicted[0] });
}
if (this.held.get(key)) {
this.log.warn('heldMessages - replacing a message on a re-used sequence number', { seqNr: key });
} else if (this.held.full) {
this.dropOldest();
}
this.held.set(key, pduObjs);
@@ -76,6 +76,16 @@ export class HeldMessages {
return this.idleWaiters.wait(() => this.held.size, timeout, signal);
}
private dropOldest(): void {
const oldest = this.held.takeOldest();
if (!oldest) return;
const [seqNr] = oldest;
this.log.warn('heldMessages - buffer full, dropping the oldest message', { max: this.max, seqNr });
}
private sweep(): void {
const expired = this.held.takeExpired();