Skip to content

[Bug] AST index can't build #59

Closed
Closed

Description

@CK-k1vv9

Termdock Version | Termdock 版本

Latest (main branch) | 最新版 (主分支)

Platform | 平台

macOS (Apple Silicon - M1 ~ M5)

Bug Description | 錯誤描述

This might be caused by the following issues:

  1. Bug in Termdock's .gitignore parser: The repository's .gitignore uses [Oo]bj/ (a character class) to ignore the obj/ directory. However, Termdock's GitignoreParser.gitignorePatternToRegex() escapes [ and ] as literal characters. As a result, the converted regex never matches the actual obj/ path. Verified behavior:
    regex: /(^|/)[Oo]bj(/.*)?$/ → match obj/ = false
  2. Cascade failure & crash loop: Because obj/ is not excluded, the worker scans the build output directory and hits project.packagespec.json. This file begins with a UTF-8 BOM, causing JSON.parse to fail. The worker attempts a regex fallback but ends up crashing with Aborted(). Upon restarting and re-initializing, the worker scans the exact same file and crashes again—triggering an infinite crash loop, which leaves indexSize: 0 and lastUpdate: 1970.

Steps to Reproduce | 重現步驟

  1. use code analysis.home.buildindex

Expected Behavior | 預期行為

No response

Screenshots | 螢幕截圖

No response

Logs | 日誌

{"timestamp":"2026-08-21T02:06:28.386Z","level":"error","message":"[ASTWorker:stderr] 🔍 [loadLanguageParser] Loading parser for language: c_sharp","source":"main-process"}
{"timestamp":"2026-08-21T02:06:29.675Z","level":"error","message":"[ASTWorker:stderr] 🔍 [loadLanguageParser] Loading parser for language: c_sharp","source":"main-process"}
{"timestamp":"2026-08-21T02:06:29.675Z","level":"error","message":"[ASTWorker:stderr] 🔍 [loadLanguageParser] Loading parser for language: c_sharp","source":"main-process"}
{"timestamp":"2026-08-21T02:06:30.037Z","level":"error","message":"[ASTWorker:stderr] Invalid JSON in /project/obj/local/project.packagespec.json, extracting keys with regex","source":"main-process"}
{"timestamp":"2026-08-21T02:06:38.453Z","level":"error","message":"[ASTWorker:stderr] Aborted()","source":"main-process"}
{"timestamp":"2026-08-21T02:06:39.511Z","level":"error","message":"[ASTWorkerManager] TIMEOUT ast_4_1787277699512","source":"main-process"}

Additional Context | 額外資訊

No response

Activity

  1. added
    bug
    on Aug 21, 2026
  2. cyh7789 commented on Aug 21, 2026

    @cyh7789
    Collaborator

    Thanks for the report, and for the diagnosis. Your first point is exactly right and we reproduced it.

    Confirmed: the gitignore character class bug. GitignoreParser.gitignorePatternToRegex() escapes [ and ] unconditionally, so [Oo]bj/ compiles to /(^|\/)\[Oo\]bj(\/.*)?$/ and only matches a directory literally named [Oo]bj. Since obj is also not in the hardcoded fallback list, nothing else catches it. This breaks every .gitignore that uses character classes: [Bb]in/, [Dd]ebug/, and the rest of the Visual Studio template. Not fixed yet, and scheduled for 1.20.

    The crash chain is already fixed on the development branch, but not in any release you can install yet. You are on 1.19.0, which is the current public release and does not contain these changes. They will ship in 1.20. Three separate changes each break a link in the chain you hit:

    • JSON and YAML no longer go through the symbol analyzers at all, so a BOM (or any malformed JSON) cannot start the cascade. This is why your log line Invalid JSON in ..., extracting keys with regex no longer exists in the current code.
    • WASM runtime death is now detected: the worker terminates itself and lets the manager respawn, and a parser that fails to load three times goes into a 60s cooldown. Repeated hangs burn a limited kill budget instead of restarting forever.
    • Generated-file and per-file size gates were wired into the indexing path, so large build artifacts are skipped rather than parsed.

    One correction to your second point: the regex fallback is plain JS string handling and cannot produce Aborted(). That message comes from the tree-sitter WASM runtime. The two were adjacent in the log, not causally linked. It does not change the outcome, since the JSON path is gone either way.

    Also worth knowing: there is no tree-sitter-c_sharp.wasm shipped, so C# files currently produce no symbols at all. Indexing a C# project will not crash once the above lands, but it will not give you much either until we add that grammar.

    Workaround until 1.20: add a plain obj/ line (no character class) to .gitignore. That keeps the build output out of the scan, which removes the trigger for the crash loop on 1.19.0 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions