fix: finalize android screenrecord mp4 on ctrl-c by signaling on-device process#249
Conversation
WalkthroughThis PR modifies screen recording behavior on Android devices to properly finalize video files. The 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/emulator.spec.ts (1)
249-260: 💤 Low valueConsider clearing the timeout on process close.
If the spawned process exits early (e.g., due to an error), the
setTimeoutcallback still fires and attempts to signal a dead process. While harmless, clearing it is cleaner.♻️ Suggested improvement
function recordThenInterruptWithCtrlC(deviceId: string, outputPath: string, recordSeconds: number): Promise<void> { return new Promise((resolve, reject) => { const child = spawn(mobilecliBinary, ['screenrecord', '--device', deviceId, '--output', outputPath], { stdio: ['pipe', 'pipe', 'pipe'], }); child.on('error', reject); - child.on('close', () => resolve()); + child.on('close', () => { + clearTimeout(timeout); + resolve(); + }); - setTimeout(() => child.kill('SIGINT'), recordSeconds * 1000); + const timeout = setTimeout(() => child.kill('SIGINT'), recordSeconds * 1000); }); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/emulator.spec.ts` around lines 249 - 260, The timeout created in recordThenInterruptWithCtrlC can fire after the child process already closed; update the function to store the timer (e.g., const timer = setTimeout(...)) and clear it when the child emits 'close' or 'error' (clearTimeout(timer)) so the callback won't attempt to kill an already-exited child; keep the existing child.on('error', reject) and child.on('close', () => { clearTimeout(timer); resolve(); }) behavior and also clear the timer in the error handler.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/emulator.spec.ts`:
- Around line 249-260: The timeout created in recordThenInterruptWithCtrlC can
fire after the child process already closed; update the function to store the
timer (e.g., const timer = setTimeout(...)) and clear it when the child emits
'close' or 'error' (clearTimeout(timer)) so the callback won't attempt to kill
an already-exited child; keep the existing child.on('error', reject) and
child.on('close', () => { clearTimeout(timer); resolve(); }) behavior and also
clear the timer in the error handler.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8ca27d40-34a9-4fde-884a-a424dcb7d028
📒 Files selected for processing (2)
devices/android.gotest/emulator.spec.ts
No description provided.