fix(FN-703): fix overly broad usage limit pattern and add transient error retry
- Narrow 'insufficient' usage-limit regex to require quota/credit/balance/fund context - Add transient error detection in executor and triage to retry instead of failing - Improve scheduler pause/resume logging with actionable messages and resume confirmation - Add SSE active connection counter for observability - Add duplicate usage-limit pause suppression logging
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import type { Request, Response } from "express";
|
||||
import type { TaskStore } from "@fusion/core";
|
||||
|
||||
let activeConnections = 0;
|
||||
|
||||
/** Returns the current number of active SSE connections. */
|
||||
export function getActiveSSEConnections(): number {
|
||||
return activeConnections;
|
||||
}
|
||||
|
||||
export function createSSE(store: TaskStore) {
|
||||
return (_req: Request, res: Response) => {
|
||||
res.setHeader("Content-Type", "text/event-stream");
|
||||
@@ -9,6 +16,8 @@ export function createSSE(store: TaskStore) {
|
||||
res.setHeader("X-Accel-Buffering", "no");
|
||||
res.flushHeaders();
|
||||
|
||||
activeConnections++;
|
||||
|
||||
// Send initial heartbeat
|
||||
res.write(": connected\n\n");
|
||||
|
||||
@@ -40,6 +49,7 @@ export function createSSE(store: TaskStore) {
|
||||
}, 30_000);
|
||||
|
||||
_req.on("close", () => {
|
||||
activeConnections--;
|
||||
clearInterval(heartbeat);
|
||||
store.off("task:created", onCreated);
|
||||
store.off("task:moved", onMoved);
|
||||
|
||||
Reference in New Issue
Block a user