Commit 533a649
committed
bugfix: Write HAR on Ctrl+C for
The `--out` file was never written. `SnifferPreference.sniff()` guarded the
write with `except KeyboardInterrupt`, but under the asyncio `async_command`
wrapper Ctrl+C raises `KeyboardInterrupt` at the `run_until_complete` level
(outside the coroutine) and then cancels the task, so the coroutine actually
receives `asyncio.CancelledError` at the `async for`. That never matched the
handler, so the HAR was silently dropped.
Move the write into a `finally` and catch `asyncio.CancelledError` alongside
`KeyboardInterrupt`, and flush to ensure the file hits disk on exit.
Claude-Session: https://claude.ai/code/session_012YD9YmyR2AQ7Gmpc1LGSTzmobile preference --out
1 parent fec6196 commit 533a649
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
139 | 143 | | |
140 | 144 | | |
141 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
142 | 148 | | |
143 | 149 | | |
| 150 | + | |
144 | 151 | | |
145 | 152 | | |
146 | 153 | | |
| |||
0 commit comments