Skip to content

Improve signal interruption handling and stale lock recovery - #6

Merged
nhan7777 merged 2 commits into
mainfrom
feature/improve-signal-interruption-handling
Sep 11, 2026
Merged

nhan7777 merged 2 commits into
mainfrom
feature/improve-signal-interruption-handling

Conversation

@nhan7777

Copy link
Copy Markdown
Owner

Summary

Addresses user-reported issue where interrupting flutter_pruner scan with Ctrl+C during long operations leaves a stale lock that blocks subsequent runs with unclear "corrupt" error messages.

Changes

1. Progress Feedback

  • File: lib/src/cli/commands/scan_command.dart:336-339
  • Change: Added "(may take 30-60s on large projects)" suffix to adapter analysis progress messages
  • Impact: Users now understand that long operations are expected, reducing impulse to interrupt

2. Improved Error Messages

  • File: lib/src/core/project/project_operation_lock.dart:73-100
  • Change: Distinguished stale armed records from actual corruption with specific recovery guidance
  • Impact: When a stale lock is detected, users get:
    • Clear explanation: "operation was interrupted and did not complete cleanup"
    • Step-by-step recovery instructions with exact commands (ps aux | grep flutter_pruner → rm → retry)
    • Distinct from genuine corruption cases that require deeper inspection
  • Test: Added test/core/project_operation_lock_test.dart:676-730 verifying stale armed detection logic

3. Documentation

  • File: doc/signal-handling.md (new)
  • Content: Comprehensive guide covering signal handling behavior, long-running operation expectations, stale lock recovery procedures, and fail-closed lock design rationale
  • Links: Added reference in README Safety section and CHANGELOG

Root Cause

When user sends SIGINT/SIGTERM during long-running dart analyze (~30s on large projects), if the Flutter Pruner process receives a second signal (or SIGKILL) during the 5-second termination cleanup window, the process terminates before writing unconfirmed/cleared records → lock file contains only armed record → next run fails with "corrupt" error.

Design Decisions

  • Fail-closed design maintained: Armed records without process identities remain authoritative blockers requiring manual verification before removal (cannot auto-clear due to PID reuse risks)
  • No second-signal blocking: User pressing Ctrl+C twice signals clear intent to force quit
  • Manual recovery acceptable: Clear guidance is better than unsafe auto-cleanup

Verification

  • ✅ Manual testing: Triggered stale lock, verified improved error message displays correct recovery steps
  • ✅ Test suite: 13/13 lock tests pass including new stale armed detection test
  • ✅ Targeted verification: dart analyze clean on modified files
  • ✅ Documentation: Comprehensive signal handling guide added

Related Issues

Fixes user-reported "Flutter Pruner process uncertainty evidence is corrupt" error when interrupting scans.

@nhan7777
nhan7777 force-pushed the feature/improve-signal-interruption-handling branch 5 times, most recently from 170480e to 5bbb15d Compare September 11, 2026 18:15
- Add progress feedback during analysis: '(may take 30-60s on large projects)' suffix
- Improve error messages: distinguish stale armed records from corruption
- Provide clear recovery steps with exact commands when stale lock detected
- Add comprehensive signal handling documentation
- Add test for stale armed record detection logic
@nhan7777
nhan7777 force-pushed the feature/improve-signal-interruption-handling branch from 5bbb15d to 9b8521d Compare September 11, 2026 18:33
- Emit 'Note: Analysis may take 30-60 seconds on large projects' before each adapter run
- Register scan.progress.analysis-note in CLI surface inventory
- Update transcript matrix fixtures for scan scenarios
- Update scan_command_test assertion to include note line

Reduces user impulse to interrupt thinking process is hung.
@nhan7777
nhan7777 merged commit 3e0844f into main Sep 11, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant