Reiniciar U_Retry al reactivar, subscription:delete y fix de grupo huérfano
- Al reactivar una suscripción (resume o detección X -> A en el dispatcher) se reinicia U_Retry de sus entregas pendientes, para que no vuelva a 'X' en el siguiente tick. - Nuevo comando subscription:delete: borra filtros, entregas fallidas y eventos de @OEVN que quedan huérfanos. - Evita TypeError en sendPendingDeliveries cuando la suscripción pasa a 'X' después de armar su grupo de envío. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e1c8ee9015
commit
ec312d9461
3 files changed
+80
-3
No files matched your search
@@ -70,3 +70,24 @@ export async function markFailedAttempt(client: ServiceLayerClient, row: Evn1Row
|
||||
U_LastSentTM: hhmmss(now),
|
||||
});
|
||||
}
|
||||
|
||||
// Pone en 0 el contador de reintentos de las entregas pendientes de una
|
||||
// suscripción. Se usa al reactivarla (State X -> A): sin esto, las filas
|
||||
// siguen con Retry >= RETRY_LIMIT y la suscripción vuelve a X en el
|
||||
// siguiente tick sin intentar enviar nada.
|
||||
export async function resetRetries(client: ServiceLayerClient, webhookId: string): Promise<number> {
|
||||
const filter = encodeURIComponent(`U_WebhookID eq '${webhookId}' and U_Status eq 'F'`);
|
||||
const rows = (await client.getAll(`/${ENTITY}?$filter=${filter}`)).map(toRow).filter((r) => r.retry > 0);
|
||||
for (const row of rows) await client.patch(`/${ENTITY}('${row.code}')`, { U_Retry: 0 });
|
||||
return rows.length;
|
||||
}
|
||||
|
||||
// Entregas fallidas/pendientes (Status='F') de una suscripción.
|
||||
export async function listPendingForWebhook(client: ServiceLayerClient, webhookId: string): Promise<Evn1Row[]> {
|
||||
const filter = encodeURIComponent(`U_WebhookID eq '${webhookId}' and U_Status eq 'F'`);
|
||||
return (await client.getAll(`/${ENTITY}?$filter=${filter}`)).map(toRow);
|
||||
}
|
||||
|
||||
export async function deleteRow(client: ServiceLayerClient, code: string): Promise<void> {
|
||||
await client.delete(`/${ENTITY}('${code}')`);
|
||||
}
|
||||
Reference in new issue
Block a user