Skip to content

Handle spawn errors and fix O(n²) line counting#139

Merged
laat merged 4 commits intomasterfrom
fix/exec-error-and-extract-perf
Apr 12, 2026
Merged

Handle spawn errors and fix O(n²) line counting#139
laat merged 4 commits intomasterfrom
fix/exec-error-and-extract-perf

Conversation

@laat
Copy link
Copy Markdown
Owner

@laat laat commented Apr 12, 2026

Summary

  • exec(): Add error handler on the spawned child and error handler on stdin to prevent the promise from hanging if node can't be found or the child exits before consuming all stdin (EPIPE)
  • extractBlocks(): Track line count incrementally across regex matches instead of markdown.slice(0, blockStart).split('\n') for each block, reducing line counting from O(n²) to O(n)

Test plan

  • All 113 tests pass
  • All 10 workspace example projects pass

laat added 4 commits April 12, 2026 18:50
- exec(): add error handlers for spawn failure and stdin EPIPE to
  prevent the promise from hanging indefinitely
- extractBlocks(): track line count incrementally across matches
  instead of slicing from the start for each block
The function is already async, so use await fs.readFile() to avoid
blocking the event loop for callers using the public API.
readme-assert README.md now works alongside --file/-f.
@laat laat merged commit b43e4b9 into master Apr 12, 2026
2 checks passed
@laat laat deleted the fix/exec-error-and-extract-perf branch April 12, 2026 17:27
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