[GH-ISSUE #1771] fix(cli): retry retained browser scenario cleanup before exit #596

Closed
opened 2026-10-15 18:26:30 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @N0zoM1z0 on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/1771

On main 6d5d71fab5e135c687f7aa2f797da19b4c2a1c1e, the one-shot capture-browser-scenario CLI creates a BrowserScenarioCapturePort inline and never calls its existing optional close().

The real PlaywrightBrowserScenarioProvider retains session cleanup callbacks after a failed session close. Its close() retries those callbacks, including releasing the browser transport before removing the private profile. MCP shutdown invokes this lifecycle, but the one-shot CLI drops its retry owner after returning the capture error.

Reproduced through the registered Incur CLI handler, the real provider, and PlaywrightScenarioBrowserCleanupOwner, with a controlled session whose first browser close rejects and second close succeeds. The CLI correctly returns cleanup_incomplete with both resources and two retained scenario steps, but calls provider.close zero times; the second browser close and profile cleanup do not happen. The red regression fails specifically on that missing provider close, after the error/partial-observation assertions pass.

This is a production-boundary failure replay: no live Chromium process or profile was created. It does not establish the cause of any earlier real-browser cleanup timeout.

Expected: attempt provider close on every capture outcome. Preserve the primary capture error/partial observation when the retry also fails; preserve an unexpected thrown capture cause; if capture succeeds but shutdown fails, return a typed cleanup failure retaining the completed Evidence. A single retry cannot guarantee recovery from persistent cleanup failures.

Related lifecycle context: #721 and #740. No matching existing fix was found via gh issue/PR searches for browser scenario cleanup and retained cleanup.

Originally created by @N0zoM1z0 on GitHub (Oct 11, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/1771 On main `6d5d71fab5e135c687f7aa2f797da19b4c2a1c1e`, the one-shot `capture-browser-scenario` CLI creates a `BrowserScenarioCapturePort` inline and never calls its existing optional `close()`. The real `PlaywrightBrowserScenarioProvider` retains session cleanup callbacks after a failed session close. Its `close()` retries those callbacks, including releasing the browser transport before removing the private profile. MCP shutdown invokes this lifecycle, but the one-shot CLI drops its retry owner after returning the capture error. Reproduced through the registered Incur CLI handler, the real provider, and `PlaywrightScenarioBrowserCleanupOwner`, with a controlled session whose first browser close rejects and second close succeeds. The CLI correctly returns `cleanup_incomplete` with both resources and two retained scenario steps, but calls provider.close zero times; the second browser close and profile cleanup do not happen. The red regression fails specifically on that missing provider close, after the error/partial-observation assertions pass. This is a production-boundary failure replay: no live Chromium process or profile was created. It does not establish the cause of any earlier real-browser cleanup timeout. Expected: attempt provider close on every capture outcome. Preserve the primary capture error/partial observation when the retry also fails; preserve an unexpected thrown capture cause; if capture succeeds but shutdown fails, return a typed cleanup failure retaining the completed Evidence. A single retry cannot guarantee recovery from persistent cleanup failures. Related lifecycle context: #721 and #740. No matching existing fix was found via `gh` issue/PR searches for browser scenario cleanup and retained cleanup.
bsakaguchi 2026-10-15 18:26:30 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#596
No description provided.