Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

An aborted bounded read frees its connection, the job worker survives a Postgres shutdown, and traverse_graph's suggested retry keeps the caller's source scope (#9622)

Garry Tan18c6fb34c019
diff --git a/changelog.d/capy-traversegraphs-retry-after-a.md b/changelog.d/capy-traversegraphs-retry-after-a.md
new file mode 100644
index 0000000000..c91e1fa569
--- /dev/null
+++ b/changelog.d/capy-traversegraphs-retry-after-a.md
@@ -0,0 +1,9 @@
+**When a scoped graph walk or typed hop chain ends early, the next call it suggests now keeps the caller's source scope.**
+
+### Fixed
+- `traverse_graph` returns a `graph_walk_truncated` notice when a walk stops at its cap, with a ready-to-run retry one level shallower. That retry dropped the caller's `source_id` and `all_sources`, so an agent that followed it walked its default source instead of the one it asked for. The retry now carries both, and still leaves them out when the call didn't set them (#8498).
+- The same holds for a `hops` chain that finds no edges, stops at an empty hop or hits a chain cap: its suggested `traverse_graph` call now keeps `source_id` and `all_sources` (#8498).
+
+### Tests
+- `test/degraded-stamp-paths.serial.test.ts` checks the retry for a walk scoped to one source, an all-sources walk and an unscoped walk.
+- `test/traverse-graph-hops.test.ts` checks the no_edges and empty_hop suggestions for the same three cases.
diff --git a/changelog.d/capy-w4-db-connection-loss.md b/changelog.d/capy-w4-db-connection-loss.md
new file mode 100644
index 0000000000..dfb462a325
--- /dev/null
+++ b/changelog.d/capy-w4-db-connection-loss.md
@@ -0,0 +1,5 @@
+**Long-running gbrain processes recover from a lost database connection: a bounded read cancelled while the database stops answering frees its connection at once, and the background job worker keeps running through a PostgreSQL shutdown instead of exiting.**
+
+### Fixed
+- A bounded read (a statement with a time limit) whose caller cancels it after it has a connection now sends the database a cancel request, discards that connection and returns at once. Before, the call waited until the database answered, and the connection stayed reserved the whole time, so a process that hit a stalled socket or pooler again and again could run out of connections. (#8155)
+- `gbrain jobs work` no longer exits when PostgreSQL shuts down and removes its local Unix socket (`connect ENOENT <dir>/.s.PGSQL.<port>`). The worker reconnects and claims again on its next poll, the same as for other lost connections. A first connect to a socket path that doesn't exist still fails at once. (#9540)
diff --git a/src/core/minions/worker.ts b/src/core/minions/worker.ts
index a5053a0fb3..e62e17b085 100644
--- a/src/core/minions/worker.ts
+++ b/src/core/minions/worker.ts
@@ -60,7 +60,7 @@ import {
import { lockRenewalAudit } from '../audit/lock-renewal-audit.ts';
import { loadavg, cpus } from 'os';
import { monitorEventLoopDelay } from 'perf_hooks';
-import { isRetryableConnError } from '../retry-matcher.ts';
+import { isRetryableConnError, isVanishedSocketError } from '../retry-matcher.ts';
import { reconnectAfterConnectionError as reconnectEngineAfterConnError } from './reconnect.ts';
import { LocalConfigurationError, isLocalConfigurationError } from './configuration-error.ts';
@@ -884,8 +884,9 @@ export class MinionWorker extends EventEmitter {
// died before the row reached us, a retry would claim a SECOND
// job (invisible active job, no renewal, later stall). So instead:
// reconnect once and let the NEXT poll tick re-claim against a live
- // pool. Non-retryable errors propagate (real bug → PM restart).
- if (!isRetryableConnError(e)) throw e;
+ // pool. Non-retryable errors propagate (real bug → PM restart). A local
+ // socket removed by a server shutdown is the same lost connection (#9540).
+ if (!isRetryableConnError(e) && !isVanishedSocketError(e)) throw e;
const msg = e instanceof Error ? e.message : String(e);
console.error(`[worker] claim hit a connection error; reconnecting, retry on next tick: ${msg}`);
await this.reconnectAfterConnectionError('claim', e);
diff --git a/src/core/ops/links.ts b/src/core/ops/links.ts
index c6bcb784ed..ec24106d9a 100644
--- a/src/core/ops/links.ts
+++ b/src/core/ops/links.ts
@@ -532,7 +532,7 @@ async function traverseChain(ctx: OperationContext, p: Record<string, unknown>,
const answers = rows.filter(r => r.role === 'answer');
const rawHops = p.hops as Array<Record<string, unknown>>;
const status = diagnostics.status;
- const fix = chainFix(slug, status, rawHops, diagnostics.empty_hop);
+ const fix = chainFix(slug, status, rawHops, readScopeArgs(p), diagnostics.empty_hop);
if (status !== 'fired' && fix) ctx.emitNotice?.({ code: 'relational_chain', kind: 'degraded', why: fix.why, fix });
const ignored = (['depth', 'link_type', 'direction'] as const).filter(k => p[k] !== undefined);
return {
@@ -547,19 +547,23 @@ async function traverseChain(ctx: OperationContext, p: Record<string, unknown>,
/** A CLI flag token built at runtime (the flag-registry generator scans literal flag strings per command). */
const cliFlag = (name: string) => `--${name}`;
-function chainFix(slug: string, status: string, hops: Array<Record<string, unknown>>, emptyHop?: number): Action | undefined {
+const readScopeArgs = (p: Record<string, unknown>) => ({
+ ...(p.source_id !== undefined ? { source_id: p.source_id } : {}), ...(p.all_sources === true ? { all_sources: true } : {}),
+});
+
+function chainFix(slug: string, status: string, hops: Array<Record<string, unknown>>, scope: Record<string, unknown>, emptyHop?: number): Action | undefined {
const hopArgs = (hs: Array<Record<string, unknown>>) => hs.flatMap(h => [cliFlag('hop'), `${String(h.link_type)}:${String(h.toward)}`]);
if (status === 'anchor_not_found') return readFix(`No page "${slug}" is visible in the searched sources; search for the entity to find its exact slug, then retry the chain with that slug.`,
{ argv: ['gbrain', 'search', slug], mcp: { tool: 'search', arguments: { query: slug } } });
if (status === 'no_edges') return readFix(`"${slug}" has no typed ${String(hops[0]?.link_type)} edges in the needed direction; the relationship may only be written as plain mentions. A depth-1 walk shows what is linked.`,
- { argv: ['gbrain', 'graph-query', slug, cliFlag('depth'), '1'], mcp: { tool: 'traverse_graph', arguments: { slug, depth: 1 } } });
+ { argv: ['gbrain', 'graph-query', slug, cliFlag('depth'), '1'], mcp: { tool: 'traverse_graph', arguments: { slug, depth: 1, ...scope } } });
if (status === 'empty_hop' && emptyHop && emptyHop > 1) {
const prefix = hops.slice(0, emptyHop - 1);
return readFix(`Hop ${emptyHop} (${String(hops[emptyHop - 1]?.link_type)}) found no typed edges from the pages hop ${emptyHop - 1} reached; the shorter chain lists those pages so you can inspect them.`,
- { argv: ['gbrain', 'graph-query', slug, ...hopArgs(prefix)], mcp: { tool: 'traverse_graph', arguments: { slug, hops: prefix } } });
+ { argv: ['gbrain', 'graph-query', slug, ...hopArgs(prefix)], mcp: { tool: 'traverse_graph', arguments: { slug, hops: prefix, ...scope } } });
}
if (status === 'truncated') return readFix('A chain cap was hit (diagnostics.cap_hit names the cap and hop), so lower-ranked answers were dropped; narrow the chain or start from a more specific page for a complete list.',
- { argv: ['gbrain', 'graph-query', slug, ...hopArgs(hops)], mcp: { tool: 'traverse_graph', arguments: { slug, hops } } });
+ { argv: ['gbrain', 'graph-query', slug, ...hopArgs(hops)], mcp: { tool: 'traverse_graph', arguments: { slug, hops, ...scope } } });
return undefined;
}
@@ -635,7 +639,9 @@ const traverse_graph: Operation = {
);
const why = `The walk stopped at its cap (${TRAVERSE_WALK_ROW_CAP} pages, ${TRAVERSE_PATH_ROW_CAP} edge rows; shallowest first), so deeper edges are missing; walk one level shallower or narrow with link_type or direction for a complete walk.`;
const fix = depth > 1 ? readFix(why, {
- mcp: { tool: 'traverse_graph', arguments: { slug, depth: depth - 1, ...(linkType ? { link_type: linkType } : {}), direction } },
+ mcp: { tool: 'traverse_graph', arguments: {
+ slug, depth: depth - 1, ...(linkType ? { link_type: linkType } : {}), direction, ...readScopeArgs(p),
+ } },
}) : undefined;
ctx.emitNotice?.({ code: 'graph_walk_truncated', kind: 'degraded', why, ...(fix ? { fix } : {}) });
}
diff --git a/src/core/persistence/bounded-reads.ts b/src/core/persistence/bounded-reads.ts
index 3536d74be6..8ff8363cac 100644
--- a/src/core/persistence/bounded-reads.ts
+++ b/src/core/persistence/bounded-reads.ts
@@ -101,7 +101,7 @@ export function boundedReads(engine: BrainEngine, clock: ClaimPhaseClock | undef
throw new PreparationDeadlineError(clock!.step, null);
}
try {
- // The clock's signal ends only the wait for a free connection (a saturated pool); the statement itself ends at the bound.
+ // The clock's signal ends the wait for a free connection (a saturated pool) and cancels a reserved statement (#8155); otherwise the statement ends at the bound.
return await target.executeRaw(sql, params, { ...opts, timeoutMs: Math.max(1, deadlineAt - Date.now()), ...(clock!.signal ? { signal: clock!.signal } : {}) });
} catch (error) {
// A connection the engine discarded after the budget's cancel (a pooler that never completed the round-trip) is the deadline too.
diff --git a/src/core/persistence/group-publish.ts b/src/core/persistence/group-publish.ts
index 9ebc38217e..e73bd03fcd 100644
--- a/src/core/persistence/group-publish.ts
+++ b/src/core/persistence/group-publish.ts
@@ -207,7 +207,7 @@ export function preparationReads(engine: BrainEngine, imports?: ImportGroupReads
};
return new Proxy(engine, { get(target, key) {
// A shared read takes no member's signal: a caller's own signal bypasses the memo, and (#6278) a bounded preparation read
- // (`timeoutMs`, whose signal only covers its connection wait) is answered once with the member's bound and signal dropped.
+ // (`timeoutMs`, ended by its bound or its signal) is answered once with the member's bound and signal dropped.
if (key === 'executeRaw') return (sql: string, params?: unknown[], opts?: { signal?: AbortSignal; timeoutMs?: number }) =>
stable.has(flat(sql)) && (!opts?.signal || opts.timeoutMs !== undefined)
? once(JSON.stringify([flat(sql), params ?? null]), () => target.executeRaw(sql, params)) : target.executeRaw(sql, params, opts);
diff --git a/src/core/postgres-engine/bounded-statement.ts b/src/core/postgres-engine/bounded-statement.ts
index bc51e0e9a9..f9efa9278b 100644
--- a/src/core/postgres-engine/bounded-statement.ts
+++ b/src/core/postgres-engine/bounded-statement.ts
@@ -8,9 +8,13 @@
* the pooler pins the transaction to one server connection, `SET LOCAL` ends
* with it, and a statement past the bound ends server-side with 57014 (a lock
* wait counts toward it). `COMMIT` after a failed statement is a rollback,
- * never an error of its own. `signal` covers only the wait for a free
+ * never an error of its own. `signal` covers the wait for a free
* connection (a saturated pool must not hold the bound off); the statement
- * itself ends at the bound, never by a cancel request. With `deadlineAt` the
+ * itself ends at the bound or, when `signal` aborts after the connection was
+ * reserved, by a cancel request: the call then rejects at once with an
+ * `AbortError` and the connection is discarded, so a socket or pooler that
+ * stopped answering never keeps it reserved (#8155). A write ended this way may
+ * have committed: its outcome is unknown. With `deadlineAt` the
* bound is the time left after the connection was reserved (#6696 B1).
*
* `jitOff` adds `SET LOCAL jit = off` to the same envelope (see
@@ -39,6 +43,8 @@ export async function runBoundedStatement<T>(conn: Sql, sql: string, params: unk
const ms = Math.max(1, Math.ceil(opts.deadlineAt !== undefined ? Math.min(opts.timeoutMs, opts.deadlineAt - Date.now()) : opts.timeoutMs));
settings.push(`SET LOCAL statement_timeout = ${ms}`);
}
+ let discarded = false;
+ let onAbort: (() => void) | undefined;
try {
const open = reserved.unsafe([READ_WRITE_BEGIN, ...settings].join('; ')).simple().execute();
// A cancellable statement is issued through `run`, which awaits the query and so enqueues it a microtask
@@ -49,11 +55,24 @@ export async function runBoundedStatement<T>(conn: Sql, sql: string, params: unk
: reserved.unsafe(sql, params as Parameters<typeof reserved.unsafe>[1], { prepare: opts.prepare ?? true }).execute();
const commit = () => reserved.unsafe('COMMIT').execute();
const close = cancellable ? read.then(commit, commit) : commit();
- const settled = await Promise.allSettled([open, read, close]);
+ const statement = Promise.allSettled([open, read, close]);
+ const settled = opts.signal && !cancellable
+ ? await Promise.race([statement, new Promise<never>((_, reject) => {
+ onAbort = () => {
+ discarded = true;
+ try { void Promise.resolve((read as { cancel?: () => unknown }).cancel?.()).catch(() => {}); } catch { /* the discard below still retires it */ }
+ reserved.discard();
+ reject(new DOMException('aborted', 'AbortError'));
+ };
+ if (opts.signal!.aborted) onAbort();
+ else opts.signal!.addEventListener('abort', onAbort, { once: true });
+ })])
+ : await statement;
for (const outcome of settled) if (outcome.status === 'rejected') throw outcome.reason;
return (settled[1] as PromiseFulfilledResult<unknown>).value as T[];
} finally {
- reserved.release();
+ if (onAbort) opts.signal?.removeEventListener('abort', onAbort);
+ if (!discarded) reserved.release();
}
}
diff --git a/src/core/retry-matcher.ts b/src/core/retry-matcher.ts
index dde17b153f..ce7f302e5c 100644
--- a/src/core/retry-matcher.ts
+++ b/src/core/retry-matcher.ts
@@ -194,6 +194,15 @@ export function isRetryableConnError(err: unknown): boolean {
return !quotesPath(msg) && CONN_PATTERNS.some(p => p.test(msg));
}
+/**
+ * #9540: a connect to a local Unix socket that is gone, because the server shut down and removed it (`connect ENOENT
+ * <dir>/.s.PGSQL.<port>`). Kept out of `isRetryableConnError`: its first-connect callers would then wait out
+ * retries on a mistyped socket path. A long-running loop that already reached the server treats it as a lost connection.
+ */
+export function isVanishedSocketError(err: unknown): boolean {
+ return getCode(err) === 'ENOENT' && (err as { syscall?: unknown }).syscall === 'connect';
+}
+
/**
* #6355: did the database session go away under a statement that was already sent? Narrower than
* `isRetryableConnError` (no auth or startup races): the connection-class SQLSTATEs, postgres.js's own
diff --git a/test/bounded-statement-abort.test.ts b/test/bounded-statement-abort.test.ts
new file mode 100644
index 0000000000..d3af5077d8
--- /dev/null
+++ b/test/bounded-statement-abort.test.ts
@@ -0,0 +1,57 @@
+/**
+ * #8155: `runBoundedStatement` with `timeoutMs` and a `signal`. An abort after the connection was reserved, while
+ * the statement is stalled on a socket or pooler that stopped answering, ends the call and discards the reserved
+ * connection instead of leaving it reserved until the driver answers.
+ */
+import { expect, test } from 'bun:test';
+import type postgres from '#postgres';
+import { runBoundedStatement } from '../src/core/postgres-engine/bounded-statement.ts';
+
+type Sql = ReturnType<typeof postgres>;
+
+function stalledPool() {
+ const counts = { releases: 0, discards: 0, cancels: 0 };
+ const pending: Array<(error: Error) => void> = [];
+ const owner = {
+ release: () => { counts.releases++; },
+ discard: () => {
+ counts.discards++;
+ for (const reject of pending.splice(0)) reject(Object.assign(new Error('Connection was discarded'), { code: 'CONNECTION_CLOSED' }));
+ },
+ unsafe: (sql: string) => {
+ const query = {
+ simple: () => query,
+ execute: () => sql.startsWith('select')
+ ? Object.assign(new Promise<never>((_, reject) => { pending.push(reject); }), { cancel: () => { counts.cancels++; } })
+ : Promise.resolve([]),
+ };
+ return query;
+ },
+ };
+ const conn = { reserve: async () => owner } as unknown as Sql;
+ return { conn, counts };
+}
+
+test('an abort after reservation ends a stalled bounded statement and discards its connection', async () => {
+ const p = stalledPool();
+ const controller = new AbortController();
+ const call = runBoundedStatement(p.conn, 'select pg_sleep(60)', [], { timeoutMs: 60_000, signal: controller.signal }, () => {});
+ setTimeout(() => controller.abort(), 20);
+ const outcome = await Promise.race([call.then(() => 'resolved', error => error), Bun.sleep(1_000).then(() => 'still pending')]);
+ expect(outcome).toMatchObject({ name: 'AbortError' });
+ expect(p.counts).toEqual({ releases: 0, discards: 1, cancels: 1 });
+});
+
+test('a bounded statement that settles before any abort releases its connection', async () => {
+ const counts = { releases: 0, discards: 0 };
+ const owner = {
+ release: () => { counts.releases++; },
+ discard: () => { counts.discards++; },
+ unsafe: () => { const query = { simple: () => query, execute: () => Promise.resolve([{ ok: 1 }]) }; return query; },
+ };
+ const controller = new AbortController();
+ const rows = await runBoundedStatement({ reserve: async () => owner } as unknown as Sql, 'select 1 as ok', [], { timeoutMs: 1_000, signal: controller.signal }, () => {});
+ controller.abort();
+ expect(rows).toEqual([{ ok: 1 }]);
+ expect(counts).toEqual({ releases: 1, discards: 0 });
+});
diff --git a/test/degraded-stamp-paths.serial.test.ts b/test/degraded-stamp-paths.serial.test.ts
index 0113f0c411..5d0084f143 100644
--- a/test/degraded-stamp-paths.serial.test.ts
+++ b/test/degraded-stamp-paths.serial.test.ts
@@ -179,6 +179,12 @@ describe('traverse_graph', () => {
expect(deep).toContain('"depth":1');
expect(deep).toContain('"link_type":"works_at"');
expect(await notice(1)).not.toContain('fix: traverse_graph');
+ const scoped = (args: Record<string, unknown>) => call('traverse_graph', { slug: 'alice-example', depth: 2, link_type: 'works_at', direction: 'out', ...args })
+ .then(o => o.content.find(c => c.text.startsWith('[gbrain notice graph_walk_truncated'))!.text);
+ expect(await scoped({ source_id: 'default' })).toContain('"source_id":"default"');
+ expect(await scoped({ all_sources: true })).toContain('"all_sources":true');
+ expect(deep).not.toContain('source_id');
+ expect(deep).not.toContain('all_sources');
} finally {
(engine as unknown as { traversePathsDetailed: unknown }).traversePathsDetailed = original;
}
diff --git a/test/traverse-graph-hops.test.ts b/test/traverse-graph-hops.test.ts
index f8acd3943f..4eb8ba83e7 100644
--- a/test/traverse-graph-hops.test.ts
+++ b/test/traverse-graph-hops.test.ts
@@ -113,6 +113,16 @@ describe('traverse_graph hops', () => {
const later = await runLocal({ slug: 'people/alice-example', hops: [HOPS[0], { link_type: 'advises', toward: 'subject' }] }, notices);
expect(later.diagnostics).toMatchObject({ status: 'empty_hop', empty_hop: 2 });
expect(notices.pop()).toMatchObject({ fix: { mcp: { tool: 'traverse_graph', arguments: { hops: [HOPS[0]] } } } });
+ await runLocal({ slug: 'companies/lonely-example', hops: [{ link_type: 'founded', toward: 'subject' }] }, notices);
+ const unscoped = (notices.pop() as any).fix.mcp.arguments;
+ expect(unscoped).not.toHaveProperty('source_id');
+ expect(unscoped).not.toHaveProperty('all_sources');
+ for (const scope of [{ source_id: 'default' }, { all_sources: true }]) {
+ await runLocal({ slug: 'companies/lonely-example', hops: [{ link_type: 'founded', toward: 'subject' }], ...scope }, notices);
+ expect(notices.pop()).toMatchObject({ fix: { mcp: { tool: 'traverse_graph', arguments: { depth: 1, ...scope } } } });
+ await runLocal({ slug: 'people/alice-example', hops: [HOPS[0], { link_type: 'advises', toward: 'subject' }], ...scope }, notices);
+ expect(notices.pop()).toMatchObject({ fix: { mcp: { tool: 'traverse_graph', arguments: { hops: [HOPS[0]], ...scope } } } });
+ }
});
test('hops is advertised on the full surface only; the starter list stays inside its budget', () => {
diff --git a/test/worker-vanished-socket-9540.test.ts b/test/worker-vanished-socket-9540.test.ts
new file mode 100644
index 0000000000..0c9ea33f9e
--- /dev/null
+++ b/test/worker-vanished-socket-9540.test.ts
@@ -0,0 +1,77 @@
+/**
+ * #9540: after PostgreSQL shuts down, its local Unix socket file is gone and the driver's next connect fails with
+ * `connect ENOENT <dir>/.s.PGSQL.<port>`. The worker's claim must treat that as a lost connection (reconnect, retry on
+ * the next tick) instead of rethrowing it and exiting. The error is the real one postgres.js raises for a socket
+ * directory with no server in it.
+ */
+import { afterAll, expect, test } from 'bun:test';
+import { mkdtempSync, rmSync } from 'fs';
+import { join } from 'path';
+import { tmpdir } from 'os';
+import postgres from '#postgres';
+import { MinionWorker } from '../src/core/minions/worker.ts';
+import type { BrainEngine } from '../src/core/engine.ts';
+import { isRetryableConnError, isVanishedSocketError } from '../src/core/retry-matcher.ts';
+
+const socketDir = mkdtempSync(join(tmpdir(), 'gbrain-no-pg-'));
+afterAll(() => rmSync(socketDir, { recursive: true, force: true }));
+
+async function vanishedSocketError(): Promise<unknown> {
+ const sql = postgres({ host: socketDir, database: 'brain', max: 1, connect_timeout: 5, onnotice: () => {} });
+ try {
+ await sql`select 1`;
+ throw new Error('expected the connect to fail');
+ } catch (error) {
+ return error;
+ } finally {
+ await sql.end({ timeout: 1 });
+ }
+}
+
+test('a connect to a vanished Unix socket is recognised; a missing file is not, and first connects still fail fast', async () => {
+ const error = await vanishedSocketError();
+ expect(error).toMatchObject({ code: 'ENOENT', syscall: 'connect' });
+ expect(isVanishedSocketError(error)).toBe(true);
+ expect(isRetryableConnError(error)).toBe(false);
+ expect(isVanishedSocketError(Object.assign(new Error("ENOENT: no such file or directory, open 'notes/a.md'"), { code: 'ENOENT', syscall: 'open' }))).toBe(false);
+});
+
+test('the worker reconnects and keeps polling when a claim finds the socket gone', async () => {
+ const error = await vanishedSocketError();
+ const events: string[] = [];
+ const engine = {
+ kind: 'postgres',
+ executeRaw: async (sql: string) => {
+ if (sql.trim() === 'SELECT 1') return [];
+ if (sql.includes('SELECT id, submission_authority FROM minion_jobs') && sql.includes('submission_authority IS DISTINCT FROM')) return [];
+ throw new Error('Unexpected SQL in worker socket fixture');
+ },
+ reconnect: async () => { events.push('reconnect'); },
+ } as unknown as BrainEngine;
+ const worker = new MinionWorker(engine, { pollInterval: 1, stalledInterval: 60_000, healthCheckInterval: 0 });
+ worker.register('noop', async () => ({}));
+ let claims = 0;
+ (worker as unknown as { queue: Record<string, unknown> }).queue = {
+ ensureSchema: async () => {},
+ hasOverdueWatchdogSuspect: async () => false,
+ promoteDelayed: async () => [],
+ claim: async () => {
+ claims += 1;
+ events.push('claim');
+ if (claims === 1) throw error;
+ worker.stop();
+ return null;
+ },
+ handleStalled: async () => ({ requeued: [], dead: [] }),
+ handleTimeouts: async () => [],
+ handleWallClockTimeouts: async () => [],
+ };
+ const origError = console.error;
+ console.error = () => {};
+ try {
+ await worker.start();
+ } finally {
+ console.error = origError;
+ }
+ expect(events).toEqual(['claim', 'reconnect', 'claim']);
+});