Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-ui): r8-l1 surface and retry failed background revalidation

Josuéf88db8667aca
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsx
index e4e5e9bc4..80496ebfb 100644
--- a/control-ui/components/GfsBrowser.tsx
+++ b/control-ui/components/GfsBrowser.tsx
@@ -709,12 +709,7 @@ export function GfsBrowser(): React.JSX.Element {
let recoveryDelay = 500
let active = true
let performVisibleStateRevalidation: (cursor?: string) => Promise<void> = async () => undefined
- const revalidationScheduler = createCoalescedRevalidation<string>(
- cursor => performVisibleStateRevalidation(cursor),
- 100
- )
- const invalidateVisibleState = (cursor?: string) => revalidationScheduler.request(cursor)
- requestStreamRevalidationRef.current = invalidateVisibleState
+ let invalidateVisibleState: (cursor?: string) => void = () => undefined
const scheduleRecovery = () => {
if (!active || recoveryTimer) return
const delay = recoveryDelay
@@ -724,6 +719,19 @@ export function GfsBrowser(): React.JSX.Element {
invalidateVisibleState()
}, delay)
}
+ const revalidationScheduler = createCoalescedRevalidation<string>(
+ cursor => performVisibleStateRevalidation(cursor),
+ error => {
+ if (!active) return
+ if (!isSilentApiError(error)) {
+ setError(error instanceof Error ? error.message : 'Failed to refresh EvenDrive')
+ }
+ scheduleRecovery()
+ },
+ 100
+ )
+ invalidateVisibleState = cursor => revalidationScheduler.request(cursor)
+ requestStreamRevalidationRef.current = invalidateVisibleState
const revalidateActionTargets = async (signal: AbortSignal) => {
const targets = new Map<string, GfsChild>()
for (const target of [selectedRef.current, renameTargetRef.current, moveTargetRef.current]) {
diff --git a/control-ui/lib/__tests__/coalescedRevalidation.test.ts b/control-ui/lib/__tests__/coalescedRevalidation.test.ts
index 9059f8376..d724e465b 100644
--- a/control-ui/lib/__tests__/coalescedRevalidation.test.ts
+++ b/control-ui/lib/__tests__/coalescedRevalidation.test.ts
@@ -4,10 +4,30 @@ import { createCoalescedRevalidation } from '../coalescedRevalidation'
describe('coalesced GFS revalidation', () => {
afterEach(() => vi.useRealTimers())
+ it('reports an unexpected failure and still runs the coalesced latest-state pass', async () => {
+ vi.useFakeTimers()
+ const failure = new Error('unexpected background revalidation failure')
+ const run = vi.fn<(_latest: string | undefined) => Promise<void>>()
+ run.mockRejectedValueOnce(failure).mockResolvedValueOnce(undefined)
+ const onError = vi.fn()
+ const revalidation = createCoalescedRevalidation(run, onError, 100)
+
+ revalidation.request('first')
+ await vi.advanceTimersByTimeAsync(100)
+ revalidation.request('latest')
+ await vi.advanceTimersByTimeAsync(100)
+
+ expect(onError).toHaveBeenCalledOnce()
+ expect(onError).toHaveBeenCalledWith(failure)
+ expect(run).toHaveBeenCalledTimes(2)
+ expect(run).toHaveBeenLastCalledWith('latest')
+ revalidation.dispose()
+ })
+
it('runs a latest-state pass within the maximum wait during a continuous burst', async () => {
vi.useFakeTimers()
const run = vi.fn(async (_latest: string | undefined) => undefined)
- const revalidation = createCoalescedRevalidation(run, 100)
+ const revalidation = createCoalescedRevalidation(run, vi.fn(), 100)
for (let index = 0; index < 20; index += 1) {
revalidation.request(`cursor-${index}`)
diff --git a/control-ui/lib/coalescedRevalidation.ts b/control-ui/lib/coalescedRevalidation.ts
index cbc0f4c70..16737eac1 100644
--- a/control-ui/lib/coalescedRevalidation.ts
+++ b/control-ui/lib/coalescedRevalidation.ts
@@ -6,6 +6,7 @@ export interface CoalescedRevalidation<T> {
/** Serialize latest-state refreshes, coalescing bursts and preserving one trailing pass. */
export function createCoalescedRevalidation<T>(
run: (latest: T | undefined) => Promise<void>,
+ onError: (error: unknown) => void,
delayMs = 100,
maxWaitMs = 1000
): CoalescedRevalidation<T> {
@@ -27,7 +28,14 @@ export function createCoalescedRevalidation<T>(
latest = undefined
running = true
void run(value)
- .catch(() => undefined)
+ .catch(error => {
+ try {
+ onError(error)
+ } catch {
+ // Error reporting must not prevent the scheduler from releasing its
+ // single-flight state or draining a queued latest-state pass.
+ }
+ })
.finally(() => {
running = false
schedule()
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 9e90e50ff..e999ef66b 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.696",
+ "version": "0.1.697",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.696",
+ "version": "0.1.697",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index aeed4c7b7..18feeeada 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.696",
+ "version": "0.1.697",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",