Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(review): harden input and terminal persistence
Chrisfbfaa32c2d5e
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/reviewStartHandler.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/reviewStartHandler.test.tsindex ffbb615bbc..1666f556c7 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/reviewStartHandler.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/reviewStartHandler.test.ts@@ -3,6 +3,8 @@ import { describe, expect, it, vi } from 'vitest';import { MAKER_INVOKE } from '../channels.js';import {+ readStartReviewRequest,+ REVIEW_START_REQUEST_LIMITS,registerReviewStartHandler,type PreparedReviewLaunch,type PreparedReviewRun,@@ -113,6 +115,57 @@ function reviewRequest(sourceSessionId = 'source-1') {}describe('maker:review:start IPC lifecycle', () => {+ it.each(+ Object.entries(REVIEW_START_REQUEST_LIMITS.attachmentMetadataChars) as Array<+ [keyof typeof REVIEW_START_REQUEST_LIMITS.attachmentMetadataChars, number]+ >,+ )('rejects oversized %s metadata before downstream normalization', (field, maxChars) => {+ expect(() =>+ readStartReviewRequest({+ sourceSessionId: 'source-1',+ attachments: [+ {+ name: 'artifact',+ [field]: ' '.repeat(maxChars + 1),+ },+ ],+ }),+ ).toThrow(`review attachment 0 ${field} is too long`);+ });++ it('rejects aggregate attachment metadata before authorization or prompt assembly', () => {+ const perAttachmentChars =+ Math.floor(+ REVIEW_START_REQUEST_LIMITS.totalAttachmentMetadataChars /+ REVIEW_START_REQUEST_LIMITS.attachmentCount,+ ) + 1;+ expect(() =>+ readStartReviewRequest({+ sourceSessionId: 'source-1',+ attachments: Array.from(+ { length: REVIEW_START_REQUEST_LIMITS.attachmentCount },+ (_, index) => ({ name: `artifact-${index}`, path: 'p'.repeat(perAttachmentChars) }),+ ),+ }),+ ).toThrow('review attachment metadata is too large in total');+ });++ it('bounds raw trimmed request fields before trim can copy oversized input', () => {+ expect(() =>+ readStartReviewRequest({+ sourceSessionId: ' '.repeat(REVIEW_START_REQUEST_LIMITS.sourceSessionIdChars + 1),+ attachments: [],+ }),+ ).toThrow('sourceSessionId required');+ expect(() =>+ readStartReviewRequest({+ sourceSessionId: 'source-1',+ focus: ' '.repeat(REVIEW_START_REQUEST_LIMITS.focusChars + 1),+ attachments: [],+ }),+ ).toThrow('review focus is too long');+ });+it('validates the caller and bounded request before preparing evidence', async () => {const harness = new IpcHarness();const reviewer = new FakeReviewer();@@ -588,6 +641,62 @@ describe('maker:review:start IPC lifecycle', () => {});});+ it('keeps both source gates until a failed terminal card write eventually persists', async () => {+ const harness = new IpcHarness();+ const reviewer = new FakeReviewer();+ let rejectFirstWrite!: (error: Error) => void;+ let rejectSecondWrite!: (error: Error) => void;+ const firstWrite = new Promise<void>((_resolve, reject) => {+ rejectFirstWrite = reject;+ });+ const secondWrite = new Promise<void>((_resolve, reject) => {+ rejectSecondWrite = reject;+ });+ const updateSourceCard = vi+ .fn<ReviewStartHandlerDeps['updateSourceCard']>()+ .mockImplementationOnce(() => firstWrite)+ .mockImplementationOnce(() => secondWrite)+ .mockResolvedValue(undefined);+ const releaseSourceLease = vi.fn(async () => undefined);+ const deps = makeDeps(reviewer, { updateSourceCard, releaseSourceLease });+ registerReviewStartHandler(harness, deps);++ await expect(harness.invoke(MAKER_INVOKE.START_REVIEW, reviewRequest())).resolves.toMatchObject({+ ok: true,+ runId: 'run-1',+ });+ reviewer.emitStatus('closed');+ await vi.waitFor(() => expect(updateSourceCard).toHaveBeenCalledTimes(1));+ expect(releaseSourceLease).not.toHaveBeenCalled();+ await expect(harness.invoke(MAKER_INVOKE.START_REVIEW, reviewRequest())).rejects.toMatchObject({+ code: 'SESSION_RUNNING',+ });++ rejectFirstWrite(new Error('database still locked'));+ await vi.waitFor(() => expect(updateSourceCard).toHaveBeenCalledTimes(2));+ expect(releaseSourceLease).not.toHaveBeenCalled();+ await expect(harness.invoke(MAKER_INVOKE.START_REVIEW, reviewRequest())).rejects.toMatchObject({+ code: 'SESSION_RUNNING',+ });++ rejectSecondWrite(new Error('database still locked'));+ await vi.waitFor(() => {+ expect(updateSourceCard).toHaveBeenCalledTimes(3);+ expect(releaseSourceLease).toHaveBeenCalledTimes(1);+ });+ expect(updateSourceCard).toHaveBeenNthCalledWith(+ 3,+ expect.objectContaining({+ meta: expect.objectContaining({ status: 'failed', failureCode: 'reviewer-closed' }),+ }),+ );+ expect(deps.warn).toHaveBeenCalledTimes(2);+ await expect(harness.invoke(MAKER_INVOKE.START_REVIEW, reviewRequest())).resolves.toMatchObject({+ ok: true,+ runId: 'run-2',+ });+ });+it('ignores continuation boundaries and lets only the first terminal event finalize', async () => {const harness = new IpcHarness();const reviewer = new FakeReviewer();diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex 13e8b511cb..9b34f7378e 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -210,6 +210,7 @@ import {type ReviewRunOwner,} from '../../shared/reviewRun.js';import {+ createRetryableReviewStartup,hasReviewOwnerProcessEnded,shouldFailInterruptedReview,} from '../reviewer/reviewRunRecovery.js';@@ -2438,16 +2439,10 @@ const reviewRunOwner: ReviewRunOwner = {instanceId: randomUUID(),processId: process.pid,};-let reviewOwnerLivenessReady: Promise<void> | null = null;--function ensureReviewOwnerLivenessReady(): Promise<void> {- if (!reviewOwnerLivenessReady) {- reviewOwnerLivenessReady = startReviewOwnerLiveness().then((handle) => {- reviewRunOwner.liveness = handle.identity;- });- }- return reviewOwnerLivenessReady;-}+const ensureReviewOwnerLivenessReady = createRetryableReviewStartup(async () => {+ const handle = await startReviewOwnerLiveness();+ reviewRunOwner.liveness = handle.identity;+});const sessionTurnLeaseTracker = new SessionTurnLeaseTracker({getDbClient,owner: reviewRunOwner,@@ -6807,25 +6802,26 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)}return sessionTurnLeaseTracker.isTurnActive(sourceSessionId);};- const reviewStartupReady = ensureReviewOwnerLivenessReady()- .then(() =>- Promise.all([+ const ensureReviewStartupReady = createRetryableReviewStartup(async () => {+ try {+ await ensureReviewOwnerLivenessReady();+ await Promise.all([reconcileInterruptedReviews(),sessionTurnLeaseTracker.reconcileStaleLeases(),cleanupOrphanedReviewArtifactSnapshots({ currentOwner: reviewRunOwner }),- ]),- )- .then(() => undefined)- .catch((error) => {+ ]);+ } catch (error) {log.error('failed to prepare Review runtime state', {error: error instanceof Error ? error.message : String(error),});throw error;- });+ }+ });// Registration happens before the renderer can invoke /review. Keep a// rejection observer here so a startup database failure is logged without- // becoming an unhandled promise; START_REVIEW still awaits and fails closed.- void reviewStartupReady.catch(() => {});+ // becoming an unhandled promise. A rejected attempt is forgotten so a later+ // START_REVIEW can retry the full reconciliation and still fail closed.+ void ensureReviewStartupReady().catch(() => {});const readLatestReviewerResult = async (reviewerSessionId: string): Promise<string> => {const rows = await getDbClient()@@ -6851,7 +6847,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)assertCaller: (event) =>assertTrustedAppRendererEvent(event as Parameters<typeof assertTrustedAppRendererEvent>[0]),waitUntilReady: async () => {- await reviewStartupReady;+ await ensureReviewStartupReady();// A supported shared-userData peer can exit after this instance starts.// Recheck ownership immediately before each run so its stale card can be// failed, while a still-live peer remains protected by the DB-backed gate.diff --git a/apps/desktop/src/main/maker-ipc/reviewStartHandler.ts b/apps/desktop/src/main/maker-ipc/reviewStartHandler.tsindex b45be6d1d4..6fbbfae84f 100644--- a/apps/desktop/src/main/maker-ipc/reviewStartHandler.ts+++ b/apps/desktop/src/main/maker-ipc/reviewStartHandler.ts@@ -27,45 +27,92 @@ export interface StartReviewRequest {attachments: ReviewAttachmentInput[];}+export const REVIEW_START_REQUEST_LIMITS = {+ sourceSessionIdChars: 512,+ focusChars: 4_000,+ attachmentCount: 20,+ attachmentBase64Chars: 32 * 1024 * 1024,+ totalBase64Chars: 64 * 1024 * 1024,+ attachmentMetadataChars: {+ name: 4_096,+ path: 32 * 1024,+ url: 64 * 1024,+ category: 32,+ mimeType: 1_024,+ originalName: 4_096,+ },+ totalAttachmentMetadataChars: 256 * 1024,+} as const;+export function readStartReviewRequest(value: unknown): StartReviewRequest {if (!value || typeof value !== 'object' || Array.isArray(value)) {throwIpcError('INVALID_PARAMS', 'review request must be an object');}const record = value as Record<string, unknown>;- if (typeof record.sourceSessionId !== 'string' || !record.sourceSessionId.trim()) {+ if (+ typeof record.sourceSessionId !== 'string' ||+ record.sourceSessionId.length > REVIEW_START_REQUEST_LIMITS.sourceSessionIdChars ||+ !record.sourceSessionId.trim()+ ) {throwIpcError('INVALID_PARAMS', 'sourceSessionId required');}- const focus = typeof record.focus === 'string' ? record.focus.trim() : '';- if (focus.length > 4_000) {- throwIpcError('INVALID_PARAMS', 'review focus is too long');+ let focus = '';+ if (typeof record.focus === 'string') {+ if (record.focus.length > REVIEW_START_REQUEST_LIMITS.focusChars) {+ throwIpcError('INVALID_PARAMS', 'review focus is too long');+ }+ focus = record.focus.trim();}const rawAttachments = record.attachments ?? [];- if (!Array.isArray(rawAttachments) || rawAttachments.length > 20) {+ if (+ !Array.isArray(rawAttachments) ||+ rawAttachments.length > REVIEW_START_REQUEST_LIMITS.attachmentCount+ ) {throwIpcError('INVALID_PARAMS', 'review attachments must be an array of at most 20 files');}let totalBase64Chars = 0;+ let totalMetadataChars = 0;const attachments: ReviewAttachmentInput[] = rawAttachments.map((item, index) => {if (!item || typeof item !== 'object' || Array.isArray(item)) {throwIpcError('INVALID_PARAMS', `review attachment ${index} must be an object`);}const attachment = item as Record<string, unknown>;- const name =- typeof attachment.name === 'string' && attachment.name.trim()- ? attachment.name.trim()- : `attachment-${index + 1}`;+ const readMetadata = (+ field: keyof typeof REVIEW_START_REQUEST_LIMITS.attachmentMetadataChars,+ ): string | undefined => {+ const raw = attachment[field];+ if (typeof raw !== 'string' || !raw) return undefined;+ if (raw.length > REVIEW_START_REQUEST_LIMITS.attachmentMetadataChars[field]) {+ throwIpcError(+ 'INVALID_PARAMS',+ `review attachment ${index} ${field} is too long`,+ );+ }+ totalMetadataChars += raw.length;+ if (totalMetadataChars > REVIEW_START_REQUEST_LIMITS.totalAttachmentMetadataChars) {+ throwIpcError('INVALID_PARAMS', 'review attachment metadata is too large in total');+ }+ return raw;+ };+ const rawName = readMetadata('name');+ const name = rawName?.trim() || `attachment-${index + 1}`;+ const attachmentPath = readMetadata('path');+ const url = readMetadata('url');+ const category = readMetadata('category');+ const mimeType = readMetadata('mimeType');+ const originalName = readMetadata('originalName');const base64 = typeof attachment.base64 === 'string' ? attachment.base64 : undefined;- if (base64 && base64.length > 32 * 1024 * 1024) {+ if (base64 && base64.length > REVIEW_START_REQUEST_LIMITS.attachmentBase64Chars) {throwIpcError('INVALID_PARAMS', `review attachment ${index} is too large`);}totalBase64Chars += base64?.length ?? 0;- if (totalBase64Chars > 64 * 1024 * 1024) {+ if (totalBase64Chars > REVIEW_START_REQUEST_LIMITS.totalBase64Chars) {throwIpcError('INVALID_PARAMS', 'review attachments are too large in total');}- const category = attachment.category;return {name,- ...(typeof attachment.path === 'string' && attachment.path ? { path: attachment.path } : {}),- ...(typeof attachment.url === 'string' && attachment.url ? { url: attachment.url } : {}),+ ...(attachmentPath ? { path: attachmentPath } : {}),+ ...(url ? { url } : {}),...(category === 'image' ||category === 'pdf' ||category === 'text' ||@@ -73,12 +120,8 @@ export function readStartReviewRequest(value: unknown): StartReviewRequest {category === 'file'? { category }: {}),- ...(typeof attachment.mimeType === 'string' && attachment.mimeType- ? { mimeType: attachment.mimeType }- : {}),- ...(typeof attachment.originalName === 'string' && attachment.originalName- ? { originalName: attachment.originalName }- : {}),+ ...(mimeType ? { mimeType } : {}),+ ...(originalName ? { originalName } : {}),...(base64 ? { base64 } : {}),};});@@ -187,6 +230,8 @@ class ReviewPreconditionError extends Error {const REVIEW_SOURCE_LEASE_RELEASE_RETRY_MS = 100;const REVIEW_SOURCE_LEASE_RELEASE_RETRY_MAX_MS = 5_000;+const REVIEW_TERMINAL_CARD_RETRY_MS = 100;+const REVIEW_TERMINAL_CARD_RETRY_MAX_MS = 5_000;/*** Register the host-owned Review lifecycle behind the same small IPC registry used@@ -227,6 +272,10 @@ export function registerReviewStartHandler(let releasePromise: Promise<void> | null = null;let releaseRetryTimer: NodeJS.Timeout | null = null;let releaseRetryDelayMs = REVIEW_SOURCE_LEASE_RELEASE_RETRY_MS;+ let terminalCardRetryTimer: NodeJS.Timeout | null = null;+ let terminalCardRetryDelayMs = REVIEW_TERMINAL_CARD_RETRY_MS;+ let pendingTerminalCard: ReviewCardWrite | null = null;+ let terminalCardPersisted = false;let sourceCardWriteChain = Promise.resolve();const enqueueSourceCardWrite = (write: () => Promise<void>): Promise<void> => {@@ -251,6 +300,9 @@ export function registerReviewStartHandler(}const release = (): Promise<void> => {+ // A running card and its durable lease are one gate. Never expose the+ // source for another /review until its terminal replacement is durable.+ if (pendingTerminalCard) return Promise.resolve();if (releasePromise) return releasePromise;const pending = (async () => {if (sourceLeaseAcquired) {@@ -287,6 +339,48 @@ export function registerReviewStartHandler(});return pending;};++ function scheduleTerminalCardRetry(): void {+ if (terminalCardRetryTimer || !pendingTerminalCard) return;+ const delayMs = terminalCardRetryDelayMs;+ terminalCardRetryDelayMs = Math.min(+ terminalCardRetryDelayMs * 2,+ REVIEW_TERMINAL_CARD_RETRY_MAX_MS,+ );+ const timer = setTimeout(() => {+ if (terminalCardRetryTimer === timer) terminalCardRetryTimer = null;+ const pendingCard = pendingTerminalCard;+ if (pendingCard) void persistTerminalCard(pendingCard);+ }, delayMs);+ timer.unref?.();+ terminalCardRetryTimer = timer;+ }++ async function persistTerminalCard(card: ReviewCardWrite): Promise<void> {+ pendingTerminalCard = card;+ try {+ await enqueueSourceCardWrite(() => deps.updateSourceCard(card));+ } catch (error) {+ deps.warn('review terminal card persist failed; retry scheduled', {+ sourceSessionId: request.sourceSessionId,+ runId,+ status: card.meta.status,+ error: error instanceof Error ? error.message : String(error),+ });+ scheduleTerminalCardRetry();+ return;+ }+ if (pendingTerminalCard !== card) return;+ terminalCardPersisted = true;+ pendingTerminalCard = null;+ if (terminalCardRetryTimer) {+ clearTimeout(terminalCardRetryTimer);+ terminalCardRetryTimer = null;+ }+ terminalCardRetryDelayMs = REVIEW_TERMINAL_CARD_RETRY_MS;+ await release();+ }+const disposeReviewerListeners = (): void => {disposeReviewEvents?.();disposeReviewEvents = null;@@ -333,19 +427,13 @@ export function registerReviewStartHandler(? { error: redactSensitiveText(error).slice(0, 2_000) }: {}),};- try {- await enqueueSourceCardWrite(() =>- deps.updateSourceCard({- sourceSessionId: request.sourceSessionId,- sourceCardClientId,- sourceAgentKind: currentSourceAgentKind,- meta: nextMeta,- result,- }),- );- } finally {- await release();- }+ await persistTerminalCard({+ sourceSessionId: request.sourceSessionId,+ sourceCardClientId,+ sourceAgentKind: currentSourceAgentKind,+ meta: nextMeta,+ result,+ });};try {@@ -430,8 +518,12 @@ export function registerReviewStartHandler('failed','',error instanceof Error ? error.message : String(error),- ).catch(async () => {- await release();+ ).catch((cardError) => {+ deps.warn('review failure card retry setup failed', {+ sourceSessionId: request.sourceSessionId,+ reviewerSessionId,+ error: cardError instanceof Error ? cardError.message : String(cardError),+ });});await closeReviewer();});@@ -451,7 +543,6 @@ export function registerReviewStartHandler(reviewerSessionId,error: error instanceof Error ? error.message : String(error),});- await release();await closeReviewer();});void terminalFinalization;@@ -533,12 +624,18 @@ export function registerReviewStartHandler(const active = activeReviewsBySource.get(request.sourceSessionId);if (active?.runId === runId) {if (sourceCardCreated) {- const message = error instanceof Error ? error.message : String(error);- const failureCode =- error instanceof ReviewPreconditionError ? error.reason.code : undefined;- await updateSourceCard('failed', '', message, failureCode).catch(async () => {- await release();- });+ if (!pendingTerminalCard && !terminalCardPersisted) {+ const message = error instanceof Error ? error.message : String(error);+ const failureCode =+ error instanceof ReviewPreconditionError ? error.reason.code : undefined;+ await updateSourceCard('failed', '', message, failureCode).catch((cardError) => {+ deps.warn('review startup failure card retry setup failed', {+ sourceSessionId: request.sourceSessionId,+ reviewerSessionId,+ error: cardError instanceof Error ? cardError.message : String(cardError),+ });+ });+ }} else {await release();}diff --git a/apps/desktop/src/main/reviewer/__tests__/reviewExternalInputWiring.test.ts b/apps/desktop/src/main/reviewer/__tests__/reviewExternalInputWiring.test.tsindex d5c6b25310..e0348ad1f2 100644--- a/apps/desktop/src/main/reviewer/__tests__/reviewExternalInputWiring.test.ts+++ b/apps/desktop/src/main/reviewer/__tests__/reviewExternalInputWiring.test.ts@@ -62,4 +62,21 @@ describe('Review external input wiring', () => {'...(evidence.workspaceFingerprint ? [] : [sourceWorkingDir])',);});++ it('retries failed startup reconciliation before admitting another Review', () => {+ expect(registerSource.match(/createRetryableReviewStartup\(/g)).toHaveLength(2);+ expect(registerSource).toContain('void ensureReviewStartupReady().catch(() => {});');+ expect(registerSource).toMatch(+ /waitUntilReady: async \(\) => \{\s+await ensureReviewStartupReady\(\);\s+[\s\S]*?await reconcileInterruptedReviews\(\);/,+ );+ const reconcileStart = registerSource.indexOf('const reconcileInterruptedReviews');+ const reconcileEnd = registerSource.indexOf(+ 'const sourceHasPersistedRunningReview',+ reconcileStart,+ );+ const reconcileSource = registerSource.slice(reconcileStart, reconcileEnd);+ expect(reconcileSource.indexOf('patchMessageAgentMeta')).toBeLessThan(+ reconcileSource.indexOf('releaseReviewSourceLease'),+ );+ });});diff --git a/apps/desktop/src/main/reviewer/__tests__/reviewRunRecovery.test.ts b/apps/desktop/src/main/reviewer/__tests__/reviewRunRecovery.test.tsindex f907b4aeb8..0fd0dfd753 100644--- a/apps/desktop/src/main/reviewer/__tests__/reviewRunRecovery.test.ts+++ b/apps/desktop/src/main/reviewer/__tests__/reviewRunRecovery.test.ts@@ -1,7 +1,10 @@import { describe, expect, it, vi } from 'vitest';import type { ReviewRunMeta, ReviewRunOwner } from '../../../shared/reviewRun.js';-import { shouldFailInterruptedReview } from '../reviewRunRecovery.js';+import {+ createRetryableReviewStartup,+ shouldFailInterruptedReview,+} from '../reviewRunRecovery.js';const currentOwner: ReviewRunOwner = { instanceId: 'current', processId: 200 };@@ -19,6 +22,30 @@ function running(owner?: ReviewRunOwner): ReviewRunMeta {}describe('Review run recovery ownership', () => {+ it('coalesces startup reconciliation and retries after a transient failure', async () => {+ let rejectFirst!: (error: Error) => void;+ const firstAttempt = new Promise<void>((_resolve, reject) => {+ rejectFirst = reject;+ });+ const start = vi+ .fn<() => Promise<void>>()+ .mockImplementationOnce(() => firstAttempt)+ .mockResolvedValue(undefined);+ const ensureReady = createRetryableReviewStartup(start);++ const first = ensureReady();+ const concurrent = ensureReady();+ expect(concurrent).toBe(first);+ expect(start).toHaveBeenCalledTimes(1);+ rejectFirst(new Error('database is temporarily locked'));+ await expect(first).rejects.toThrow('database is temporarily locked');++ await expect(ensureReady()).resolves.toBeUndefined();+ expect(start).toHaveBeenCalledTimes(2);+ await expect(ensureReady()).resolves.toBeUndefined();+ expect(start).toHaveBeenCalledTimes(2);+ });+it('does not fail a run owned by this process instance', async () => {const probe = vi.fn(() => false);await expect(diff --git a/apps/desktop/src/main/reviewer/reviewRunRecovery.ts b/apps/desktop/src/main/reviewer/reviewRunRecovery.tsindex c71beb172d..523cc4b3bd 100644--- a/apps/desktop/src/main/reviewer/reviewRunRecovery.ts+++ b/apps/desktop/src/main/reviewer/reviewRunRecovery.ts@@ -10,6 +10,30 @@ export type ReviewOwnerLivenessProbe = () => ReviewOwnerLivenessProbeResult | Promise<ReviewOwnerLivenessProbeResult>;export type ReviewRunOwnerStatus = 'alive' | 'ended' | 'unknown';+/**+ * Coalesce concurrent startup reconciliation, but forget a rejected attempt so+ * the next /review can recover from a transient database failure without an app restart.+ */+export function createRetryableReviewStartup(+ start: () => Promise<void>,+): () => Promise<void> {+ let attempt: Promise<void> | null = null;+ return () => {+ if (attempt) return attempt;+ let current: Promise<void>;+ try {+ current = Promise.resolve(start());+ } catch (error) {+ current = Promise.reject(error);+ }+ attempt = current;+ void current.catch(() => {+ if (attempt === current) attempt = null;+ });+ return current;+ };+}+export function isReviewProcessAlive(processId: number): boolean {try {process.kill(processId, 0);