Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop): rp-014 rp-015 retry a dropped cluster stream during cleanup
M4308af5598c9
diff --git a/desktop-app/test/__tests__/gfsTransportRetry.test.ts b/desktop-app/test/__tests__/gfsTransportRetry.test.tsnew file mode 100644index 000000000..b40a462b8--- /dev/null+++ b/desktop-app/test/__tests__/gfsTransportRetry.test.ts@@ -0,0 +1,84 @@+import { describe, expect, it } from 'vitest'+import { isTransportNoise, withTransportRetry } from '../e2e-playwright/gfsTransportRetry'++/**+ * The GFS journeys reach the cluster through one `kubectl exec` per call, and+ * that stream can end early. The retry must absorb exactly that — and nothing+ * else, or a real failure would be retried into a false pass.+ */+describe('GFS E2E transport retry', () => {+ describe('isTransportNoise', () => {+ it('recognises a dropped exec stream', () => {+ expect(isTransportNoise(new Error('Command failed: kubectl ...\nerror: EOF'))).toBe(true)+ })++ it('recognises a dropped stream nested in an AggregateError', () => {+ // The shared harness reports a failed cleanup this way: the AggregateError+ // message does NOT carry the cause.+ const aggregate = new AggregateError(+ [new Error('Command failed: kubectl exec\nerror: EOF')],+ 'failed to fully clean GFS fixture e2e-gfs-dnd-file-abc'+ )+ expect(isTransportNoise(aggregate)).toBe(true)+ })++ it('does not treat a real failure as transport noise', () => {+ expect(isTransportNoise(new Error('share_revocation_rejected'))).toBe(false)+ expect(isTransportNoise(new Error('fixture e2e-gfs-dnd-file-abc leaked'))).toBe(false)+ expect(isTransportNoise(new AggregateError([new Error('not_empty')], 'cleanup failed'))).toBe(+ false+ )+ })+ })++ describe('withTransportRetry', () => {+ it('returns the first successful result', async () => {+ await expect(withTransportRetry('probe', () => 'ok', 1)).resolves.toBe('ok')+ })++ it('retries once on a dropped stream and succeeds', async () => {+ let attempts = 0+ const result = await withTransportRetry(+ 'probe',+ () => {+ attempts += 1+ if (attempts === 1) throw new Error('error: EOF')+ return 'ok'+ },+ 1+ )+ expect(result).toBe('ok')+ expect(attempts).toBe(2)+ })++ it('propagates a real failure without retrying it', async () => {+ let attempts = 0+ await expect(+ withTransportRetry(+ 'probe',+ () => {+ attempts += 1+ throw new Error('share_revocation_rejected')+ },+ 1+ )+ ).rejects.toThrow(/share_revocation_rejected/)+ expect(attempts).toBe(1)+ })++ it('propagates a second dropped stream', async () => {+ let attempts = 0+ await expect(+ withTransportRetry(+ 'probe',+ () => {+ attempts += 1+ throw new Error('error: EOF')+ },+ 1+ )+ ).rejects.toThrow(/EOF/)+ expect(attempts).toBe(2)+ })+ })+})diff --git a/desktop-app/test/e2e-playwright/gfs-drag-and-drop-desktop.test.ts b/desktop-app/test/e2e-playwright/gfs-drag-and-drop-desktop.test.tsindex d61172c4b..91f033d2c 100644--- a/desktop-app/test/e2e-playwright/gfs-drag-and-drop-desktop.test.ts+++ b/desktop-app/test/e2e-playwright/gfs-drag-and-drop-desktop.test.ts@@ -40,6 +40,7 @@ import {seedGfsGrant,uniqueGfsFixtureName,} from '../../../tests/e2e/gfsUiFixtures'+import { withTransportRetry } from './gfsTransportRetry'import { launchAndLogin } from './workflowUi'function gridRow(page: Page, name: string): Locator {@@ -50,25 +51,6 @@ function toast(page: Page, text: string): Locator {return page.locator('[role="status"], [role="alert"]').filter({ hasText: text })}-/**- * A dropped `kubectl exec` stream is transport noise, not a verdict: the- * shared harness opens one exec session per call and the stream can end- * early. One bounded retry keeps the journey setup deterministic; a second- * failure propagates.- */-async function withTransportRetry<T>(what: string, action: () => T): Promise<T> {- for (let attempt = 1; ; attempt += 1) {- try {- return action()- } catch (caught) {- const message = caught instanceof Error ? caught.message : String(caught)- const transportNoise = /\bEOF\b|socket hang up|connection reset|stream closed/i.test(message)- if (attempt >= 2 || !transportNoise) throw caught- await new Promise(resolve => setTimeout(resolve, 1_500))- }- }-}-/*** Grant the fixture to the seeded E2E persona: read/write/delete, inherited* by the fixture subtree. Without this the fixtures exist but the persona@@ -98,6 +80,20 @@ async function seedFixtureFile(name: string) {return withTransportRetry('seedGfsFileFixture', () => seedGfsFileFixture(name))}+/**+ * Remove a fixture and prove it is gone, with one bounded transport retry.+ *+ * The cleanup is part of the lane's contract, and the shared harness reaches+ * the cluster through one `kubectl exec` per call — a dropped stream there+ * aborts the cleanup BEFORE it writes the tombstone, which leaves the seeded+ * rows live. A retry is the difference between a transport hiccup and a+ * dirty shared drive; a second failure still fails the journey.+ */+async function removeFixture(name: string): Promise<void> {+ await withTransportRetry('cleanupGfsFixture', () => cleanupGfsFixture(name))+ await withTransportRetry('assertGfsFixtureCleaned', () => assertGfsFixtureCleaned(name))+}+/*** Open the Files surface at the shared root.*@@ -217,8 +213,7 @@ test.describe('EvenDrive drag and drop (desktop grid)', () => {await expect(fileRow).toBeHidden({ timeout: 30_000 })} finally {await app?.close().catch(() => undefined)- cleanupGfsFixture(fixtureName)- assertGfsFixtureCleaned(fixtureName)+ await removeFixture(fixtureName)}})@@ -301,10 +296,8 @@ test.describe('EvenDrive drag and drop (desktop grid)', () => {).toBeNull()} finally {await app?.close().catch(() => undefined)- cleanupGfsFixture(sourceName)- cleanupGfsFixture(destinationName)- assertGfsFixtureCleaned(sourceName)- assertGfsFixtureCleaned(destinationName)+ await removeFixture(sourceName)+ await removeFixture(destinationName)}})})diff --git a/desktop-app/test/e2e-playwright/gfsTransportRetry.ts b/desktop-app/test/e2e-playwright/gfsTransportRetry.tsnew file mode 100644index 000000000..6752e5220--- /dev/null+++ b/desktop-app/test/e2e-playwright/gfsTransportRetry.ts@@ -0,0 +1,57 @@+// desktop-app/test/e2e-playwright/gfsTransportRetry.ts+//+// Bounded retry for the cluster calls the GFS journeys make.+//+// The shared fixture harness reaches the cluster through one `kubectl exec` per+// call, and that stream can end early ("error: EOF"). That is transport+// noise, not a verdict: without a retry a hiccup during the SETUP leaves+// seeded rows on the shared drive, and a hiccup during the CLEANUP aborts it+// before it writes the tombstone — the drive is left dirty either way.+//+// The discrimination is deliberately narrow: only a dropped stream is retried.+// A real failure (a rejected mutation, a missing row, an assertion) propagates+// on the first attempt, so a retry can never turn a failed journey green.++/**+ * True when the failure is a dropped transport stream.+ *+ * The shared harness reports a failed cleanup as an AggregateError whose own+ * message does NOT carry the cause, so the nested errors are inspected too —+ * otherwise the retry would never fire for exactly the case it exists for.+ */+export function isTransportNoise(caught: unknown): boolean {+ const parts: string[] = []+ const collect = (value: unknown): void => {+ if (value instanceof Error) {+ parts.push(value.message)+ const nested = (value as AggregateError).errors+ if (Array.isArray(nested)) nested.forEach(collect)+ } else {+ parts.push(String(value))+ }+ }+ collect(caught)+ return /\bEOF\b|socket hang up|connection reset|stream closed/i.test(parts.join(' | '))+}++/** Run `action`, retrying once when the failure is a dropped transport stream. */+export async function withTransportRetry<T>(+ what: string,+ action: () => T,+ delayMs = 1_500+): Promise<T> {+ for (let attempt = 1; ; attempt += 1) {+ try {+ return action()+ } catch (caught) {+ if (attempt >= 2 || !isTransportNoise(caught)) {+ throw new Error(`[gfs-dnd] ${what} failed: ${describe(caught)}`, { cause: caught })+ }+ await new Promise(resolve => setTimeout(resolve, delayMs))+ }+ }+}++function describe(caught: unknown): string {+ return caught instanceof Error ? caught.message : String(caught)+}