fix(reply): fix duplicate block replies by unblocking coalesced payloads (#5080)

Merged via squash.

Prepared head SHA: 399e1259cb935e46123864143c7f8879b5ff459c
Co-authored-by: yassine20011 <59234686+yassine20011@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
Yassine Amjad
2026-02-28 22:51:43 +00:00
committed by GitHub
parent c58d2aa99e
commit 61989091a4
2 changed files with 8 additions and 6 deletions

View File

@@ -0,0 +1 @@
- Clarify block reply pipeline seen-check parameter naming for maintainability (#5080) (thanks @yassine20011)

View File

@@ -90,12 +90,12 @@ export function createBlockReplyPipeline(params: {
let didStream = false;
let didLogTimeout = false;
const sendPayload = (payload: ReplyPayload, skipSeen?: boolean) => {
const sendPayload = (payload: ReplyPayload, bypassSeenCheck: boolean = false) => {
if (aborted) {
return;
}
const payloadKey = createBlockReplyPayloadKey(payload);
if (!skipSeen) {
if (!bypassSeenCheck) {
if (seenKeys.has(payloadKey)) {
return;
}
@@ -155,7 +155,7 @@ export function createBlockReplyPipeline(params: {
shouldAbort: () => aborted,
onFlush: (payload) => {
bufferedKeys.clear();
sendPayload(payload);
sendPayload(payload, /* bypassSeenCheck */ true);
},
})
: null;
@@ -186,7 +186,7 @@ export function createBlockReplyPipeline(params: {
}
for (const payload of bufferedPayloads) {
const finalPayload = buffer?.finalize?.(payload) ?? payload;
sendPayload(finalPayload, true);
sendPayload(finalPayload, /* bypassSeenCheck */ true);
}
bufferedPayloads.length = 0;
bufferedPayloadKeys.clear();
@@ -202,7 +202,7 @@ export function createBlockReplyPipeline(params: {
const hasMedia = Boolean(payload.mediaUrl) || (payload.mediaUrls?.length ?? 0) > 0;
if (hasMedia) {
void coalescer?.flush({ force: true });
sendPayload(payload);
sendPayload(payload, /* bypassSeenCheck */ false);
return;
}
if (coalescer) {
@@ -210,11 +210,12 @@ export function createBlockReplyPipeline(params: {
if (seenKeys.has(payloadKey) || pendingKeys.has(payloadKey) || bufferedKeys.has(payloadKey)) {
return;
}
seenKeys.add(payloadKey);
bufferedKeys.add(payloadKey);
coalescer.enqueue(payload);
return;
}
sendPayload(payload);
sendPayload(payload, /* bypassSeenCheck */ false);
};
const flush = async (options?: { force?: boolean }) => {