Commit 2217947
authored
fix(init): add size guard and deduplicate JSON minification in preReadCommonFiles (#713)
## Summary
Two fixes for `preReadCommonFiles`:
1. **Per-file size guard** -- Stat files before reading and skip
anything over `MAX_FILE_BYTES` (256KB). Prevents memory spikes from
large files like `Gemfile.lock` that could eat the entire 512KB budget
in one read.
2. **Deduplicate JSON minification** -- Extract `minifyJson()` helper
used by both `preReadCommonFiles` and `readSingleFile`. Prevents the two
identical `JSON.stringify(JSON.parse())` blocks from drifting out of
sync.
## Test plan
- [x] All 68 local-ops tests pass
- [x] Typecheck clean
- [x] Lint clean
Made with [Cursor](https://cursor.com)1 parent f997526 commit 2217947
1 file changed
+15
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
| |||
387 | 396 | | |
388 | 397 | | |
389 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
390 | 403 | | |
391 | 404 | | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 405 | + | |
397 | 406 | | |
398 | 407 | | |
399 | 408 | | |
| |||
540 | 549 | | |
541 | 550 | | |
542 | 551 | | |
543 | | - | |
544 | 552 | | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
| 553 | + | |
550 | 554 | | |
551 | 555 | | |
552 | 556 | | |
| |||
0 commit comments