[GH-ISSUE #4251] [Bug] ADB screen capture publishes after cancellation before output commit #1675

Closed
opened 2026-10-16 21:08:54 +00:00 by bsakaguchi · 1 comment
Owner

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

[Bug] ADB screen capture publishes after cancellation before output commit

Area: Evidence, artifacts, or reconstruction
Interface: CLI and MCP share AdbProvider; boundary probe called the provider directly
Earliest failure stage: Cleanup, cancellation, or lifecycle

Observed behavior

At source revision 0e1f0bf2d06943e59253b8a66923a1ae6005e81e, capture_adb_screen returns success and creates screen.png when the caller's AbortSignal is aborted after the screencap command returns but before the local output write begins. This is a controlled production-boundary result with a stubbed adb process and temporary output directory; no device was contacted.

The path in src/adb/AdbProvider.ts:2208-2238 awaits runAdbCapture(..., signal) and then proceeds through PNG header parsing and writeFile without checking the signal. It returns success with the output path, byte count, digest, and dimensions. A cancellation observed before publication therefore does not stop publication or produce a typed cancellation result.

Reproduction

Run the focused disposable probe from the repository root:

PATH=/opt/homebrew/opt/node@24/bin:$PATH node_modules/.bin/vitest run --config .cache/codebase-audit/artifacts/vitest.audit.config.mts --reporter=verbose

The test abort after screencap completion but before file publication currently returns success uses a stubbed execFileBytes that aborts the signal before resolving with a 24-byte PNG-signature/IHDR header. The public provider call is AdbProvider.execute({ operation: "capture_adb_screen", input: { serial: "device", output_directory: <temp> } }, { signal }). Observed result: ok: true, screen.png exists, and its dimensions are 1 x 1. The control case leaves the signal active and also succeeds with the expected file. The header fixture is sufficient for the current parsePngDimensions boundary; this does not verify real PNG decoder behavior.

Six disposable ADB probes passed: stable and cancelled screen capture, stable and replaced-path install, and stable and replaced-path push. Runtime was Node v24.18.0, macOS arm64. Probe file: .cache/codebase-audit/artifacts/adbAudit.test.ts.

Expected behavior

Check cancellation after the adb command completes and before creating the output file. If cancellation races with an already-started write, return typed cancellation with an explicit partial observation/publication receipt that identifies the retained file and its verified digest; do not imply that cancellation prevented publication. The caller's output must remain intact once publication has committed.

Impact and scope

A cancelled screen-capture request can still write a caller-visible file and report success. This affects the shared provider behavior reached by CLI and MCP. Only the controlled provider boundary was exercised; real-device timing and platform-specific filesystem behavior remain unverified.

Relevant evidence and dedupe

  • src/adb/AdbProvider.ts:2208-2238 is the producer and publication boundary.
  • The probe command above passed 2 screen cases: one stable control and one abort-before-publication trigger.
  • Dedupe search: gh issue list --repo morluto/rea --state all --search 'repo:morluto/rea capture_adb_screen cancel' --limit 20 returned no matching focused issue. The broad lifecycle audit #4227 is related context, not this concrete behavior.
  • No real Android device was contacted; no real-device reproduction is claimed.
Originally created by @morluto on GitHub (Oct 15, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/4251 # [Bug] ADB screen capture publishes after cancellation before output commit **Area:** Evidence, artifacts, or reconstruction **Interface:** CLI and MCP share `AdbProvider`; boundary probe called the provider directly **Earliest failure stage:** Cleanup, cancellation, or lifecycle ## Observed behavior At source revision `0e1f0bf2d06943e59253b8a66923a1ae6005e81e`, `capture_adb_screen` returns success and creates `screen.png` when the caller's `AbortSignal` is aborted after the screencap command returns but before the local output write begins. This is a controlled production-boundary result with a stubbed adb process and temporary output directory; no device was contacted. The path in `src/adb/AdbProvider.ts:2208-2238` awaits `runAdbCapture(..., signal)` and then proceeds through PNG header parsing and `writeFile` without checking the signal. It returns success with the output path, byte count, digest, and dimensions. A cancellation observed before publication therefore does not stop publication or produce a typed cancellation result. ## Reproduction Run the focused disposable probe from the repository root: ```sh PATH=/opt/homebrew/opt/node@24/bin:$PATH node_modules/.bin/vitest run --config .cache/codebase-audit/artifacts/vitest.audit.config.mts --reporter=verbose ``` The test `abort after screencap completion but before file publication currently returns success` uses a stubbed `execFileBytes` that aborts the signal before resolving with a 24-byte PNG-signature/IHDR header. The public provider call is `AdbProvider.execute({ operation: "capture_adb_screen", input: { serial: "device", output_directory: <temp> } }, { signal })`. Observed result: `ok: true`, `screen.png` exists, and its dimensions are `1 x 1`. The control case leaves the signal active and also succeeds with the expected file. The header fixture is sufficient for the current `parsePngDimensions` boundary; this does not verify real PNG decoder behavior. Six disposable ADB probes passed: stable and cancelled screen capture, stable and replaced-path install, and stable and replaced-path push. Runtime was Node `v24.18.0`, macOS arm64. Probe file: `.cache/codebase-audit/artifacts/adbAudit.test.ts`. ## Expected behavior Check cancellation after the adb command completes and before creating the output file. If cancellation races with an already-started write, return typed cancellation with an explicit partial observation/publication receipt that identifies the retained file and its verified digest; do not imply that cancellation prevented publication. The caller's output must remain intact once publication has committed. ## Impact and scope A cancelled screen-capture request can still write a caller-visible file and report success. This affects the shared provider behavior reached by CLI and MCP. Only the controlled provider boundary was exercised; real-device timing and platform-specific filesystem behavior remain unverified. ## Relevant evidence and dedupe - `src/adb/AdbProvider.ts:2208-2238` is the producer and publication boundary. - The probe command above passed 2 screen cases: one stable control and one abort-before-publication trigger. - Dedupe search: `gh issue list --repo morluto/rea --state all --search 'repo:morluto/rea capture_adb_screen cancel' --limit 20` returned no matching focused issue. The broad lifecycle audit [#4227](https://github.com/morluto/rea/issues/4227) is related context, not this concrete behavior. - No real Android device was contacted; no real-device reproduction is claimed.
bsakaguchi 2026-10-16 21:08:54 +00:00
  • closed this issue
  • added the
    triage
    bug
    labels
Author
Owner

@morluto commented on GitHub (Oct 16, 2026):

Fixed on main in 461eb1612. Screen capture now stops before publication when cancellation arrives before commit, and preserves the committed publication receipt when cancellation arrives afterwards.

Both sides of the cutoff were tested with a valid PNG and real temporary filesystem writes; ADB replies were simulated.

Hosted main CI is still pending; this closure is based on the implemented fix and the scoped regression evidence.

<!-- gh-comment-id:6206018625 --> @morluto commented on GitHub (Oct 16, 2026): Fixed on `main` in [461eb1612](https://github.com/morluto/rea/commit/461eb161282237ad3135f6d8f8fbbc560285548e). Screen capture now stops before publication when cancellation arrives before commit, and preserves the committed publication receipt when cancellation arrives afterwards. Both sides of the cutoff were tested with a valid PNG and real temporary filesystem writes; ADB replies were simulated. Hosted main CI is still pending; this closure is based on the implemented fix and the scoped regression evidence.
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#1675
No description provided.