fix(wh): immediately flush if overflow
Build and Deploy / build-and-deploy (push) Successful in 1m51s
Build and Deploy / build-and-deploy (push) Successful in 1m51s
This commit is contained in:
+13
-1
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user