Commit 6a19c6b
fix(cli): prevent
## What changes for users
`mops check --fix` no longer crashes when `moc` produces no output.
Previously the autofix pass aborted the entire command with an unhandled
exception:
```
TypeError: Cannot read properties of undefined (reading 'split')
at parseDiagnostics (.../dist/helpers/autofix-motoko.js)
```
This was blocking deployments in memory-constrained environments
(CI/containers) where `moc` can fail to spawn or get OOM-killed —
`execa(..., { reject: false })` then resolves with `stdout ===
undefined`. Even unrelated frontend-only changes couldn't ship because
the backend `check --fix` step crashed.
## Why
`parseDiagnostics(stdout: string)` assumed `moc` always returns captured
stdout. With `reject: false`, a failed/killed `moc` yields `undefined`,
and `.split()` threw. Reported by multiple users in production.
**Before:** any `moc` spawn/kill failure during `--fix` → hard crash,
command aborts.
**After:** missing output is treated as "no fixes to apply"; the
subsequent regular check reports the real failure (e.g. non-zero exit)
with a clear message.
## Notes
Targeted unit test added for the `undefined` / empty stdout paths.
Made with [Cursor](https://cursor.com)
Co-authored-by: Cursor <cursoragent@cursor.com>check --fix crash when moc produces no output (#570)1 parent 851929f commit 6a19c6b
3 files changed
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
| |||
0 commit comments