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 flushed = new Set<string>();
|
||||
existing.data = merge(
|
||||
const merged = merge(
|
||||
oldData,
|
||||
body,
|
||||
undefined,
|
||||
MAX_FIELD_LENGTH,
|
||||
flushed,
|
||||
);
|
||||
existing.data = merged;
|
||||
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) {
|
||||
existing.count = 1;
|
||||
forward(id, url, oldData);
|
||||
|
||||
Reference in New Issue
Block a user