Skip to content

fix(cli): surface lock-acquisition errors and silence Emscripten Aborted() spam#9

Open
mschreib28 wants to merge 2 commits into
mainfrom
upstream/fix/cli-lock-error-and-wasm-stderr
Open

fix(cli): surface lock-acquisition errors and silence Emscripten Aborted() spam#9
mschreib28 wants to merge 2 commits into
mainfrom
upstream/fix/cli-lock-error-and-wasm-stderr

Conversation

@mschreib28
Copy link
Copy Markdown
Owner

Summary\n\nTwo small, unrelated CLI cosmetic bugs that show up when the indexer is under load. Both are actively misleading rather than just noisy.\n\n### 1. Lock-acquisition error hidden behind "No files found to index"\n\nprintIndexResult falls through to 'No files found to index' whenever filesIndexed === 0 && filesErrored === 0. The lock-acquisition path in indexAll/sync returns { success: false, errors: [{ message: 'Could not acquire file lock ...', severity: 'error' }] }, but filesErrored counts only file-level parse failures — so the lock-failure message never gets shown. The user sees "No files found to index" while another indexer is actively running.\n\nAdded a check at the top of printIndexResult that surfaces the first generic error when result.success === false.\n\n### 2. Emscripten Aborted() spam leaking to the parent terminal\n\nWhen tree-sitter WASM crashes on a pathological file (large generated C/C++ headers, etc.), the parse worker correctly catches the RuntimeError: memory access out of bounds and exits with code 1 — but Emscripten itself prints Aborted() (and a follow-up Build with -sASSERTIONS for more info line) directly to stderr before the JS handler runs. Those lines leak to the parent's terminal even though the JS layer recovers cleanly. Re-indexing a repo with WASM-prone files produces dozens of Aborted() lines.\n\nInstalled a startup-time process.stderr.write filter in parse-worker.ts that drops only those two specific Emscripten internal lines. Everything we log ourselves (via console.* / parentPort.postMessage) passes through unchanged.\n\n## Test plan\n\nVerified live against ollama/ollama@v0.22.0 (1.2 GB repo, 1,179 indexed files including vendored llama.cpp / MLX-C):\n\n- [x] codegraph index while another indexer is running now shows Could not acquire file lock - another process may be indexing (was: "No files found to index")\n- [x] Re-index of a repo that had previously triggered WASM-abort lines: 0 Aborted() lines (was: 68+)\n- [x] npx tsc --noEmit passes\n- [x] npm run build succeeds\n\n🤖 Generated with Claude Code\n


Copied from colbymchenry/codegraph#128

…ted() spam

Two unrelated cosmetic but actively misleading bugs that surface when
the indexer is under load.

1) printIndexResult fell through to "No files found to index" whenever
   the IndexResult had filesIndexed=0 AND filesErrored=0. The
   lock-acquisition path returns success:false with a generic
   "Could not acquire file lock" entry in result.errors[] (severity
   'error'), but filesErrored counts only file-level parse failures,
   so the user saw "No files found to index" — actively wrong.
   Add a top-of-function check for the !success && !hasErrors case
   that surfaces the first severity:'error' message instead.

2) parse-worker.ts let Emscripten's stderr "Aborted()" lines (plus
   their "Build with -sASSERTIONS for more info" follow-ups) leak to
   the parent's terminal whenever a WASM tree-sitter parser crashed
   on a pathological file. Even after the JS layer caught and recovered,
   the user saw dozens of `Aborted()` lines spammed to stderr. Install
   a stderr filter at worker startup that drops only those specific
   Emscripten internal lines; everything we log ourselves passes
   through unchanged.

Verified live against ollama/ollama@v0.22.0:
  - second concurrent `codegraph index` now shows
    "Could not acquire file lock - another process may be indexing"
    instead of "No files found to index"
  - WASM-crash-prone re-index produced 0 Aborted() lines (down from 68+).
…docs

Two reviewer findings on PR colbymchenry#128:

- printIndexResult: when result.success is false but result.errors
  contains no severity:'error' entry (degenerate case but possible
  if the result shape ever drifts), the find() returned undefined
  and the previous if-guard fell through to the misleading
  'No files found to index' branch. Now always surfaces a clear
  failure message via clack.log.error, defaulting to 'Indexing
  failed — no further details available' when no specific error
  is in the errors list.

- parse-worker stderr filter: callback handling was already correct
  but the comment didn't document it; expand the comment to spell
  out the Writable-stream-contract obligation, the per-call match
  semantics (split-chunk caveat), and the substring-exactness
  trade-off so future readers understand the deliberate trade-offs.
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.

2 participants