fix(wh): immediately flush if overflow
Build and Deploy / build-and-deploy (push) Successful in 1m51s

This commit is contained in:
2026-07-14 16:56:36 +07:00 Unverified
parent 5edea18687
commit b793a6ca9b
+13 -1
View File
@@ -33,15 +33,27 @@ export function webhookMerger(app: App) {
const oldData = existing.data; const oldData = existing.data;
const flushed = new Set<string>(); const flushed = new Set<string>();
existing.data = merge( const merged = merge(
oldData, oldData,
body, body,
undefined, undefined,
MAX_FIELD_LENGTH, MAX_FIELD_LENGTH,
flushed, flushed,
); );
existing.data = merged;
existing.count++; existing.count++;
if (JSON.stringify(merged).length > 2000) {
existing.data = body;
existing.count = 1;
forward(id, url, oldData);
existing.timer = setTimeout(
() => forward(id, url, existing.data),
bufferTime,
);
return status(202);
}
if (flushed.size > 0) { if (flushed.size > 0) {
existing.count = 1; existing.count = 1;
forward(id, url, oldData); forward(id, url, oldData);