Summary
gbrain search and gbrain query print correct results but the process never exits on PGLite. The search logic itself works — results appear within 1-2 seconds — but the bun process hangs at ~27% CPU indefinitely until killed. This affects both the production brain (91 pages) and a minimal 3-page repro.
Environment
- gbrain: v0.37.3.0 (commit
54a0629, upgraded from 772253e — same behavior on both)
- OS: macOS 26.3 (arm64, Mac mini M-series)
- bun: 1.3.14 (Homebrew)
- Node: 25.8.1 (Homebrew)
- Engine: PGLite (local), schema v80
- Embedding:
openai:text-embedding-3-small (1536d)
- Search mode: tested
conservative, tokenmax, and balanced — all hang
Minimal Reproduction
export GBRAIN_HOME=/tmp/gbrain-repro
mkdir -p $GBRAIN_HOME /tmp/repro-source
# Requires OPENAI_API_KEY in env
gbrain init --pglite --embedding-model openai:text-embedding-3-small
mkdir -p /tmp/repro-source
cat > /tmp/repro-source/one.md <<'EOF'
---
title: First note
---
The quick brown fox jumps over the lazy dog. Pangram test.
EOF
cat > /tmp/repro-source/two.md <<'EOF'
---
title: Second note
---
Lorem ipsum dolor sit amet. HMAC contact hashing. Pangram.
EOF
cat > /tmp/repro-source/three.md <<'EOF'
---
title: Third note
---
Brown fox testing. Outbox approval queue.
EOF
git -C /tmp/repro-source init && git -C /tmp/repro-source add -A && git -C /tmp/repro-source commit -m "repro"
gbrain sources add repro --path /tmp/repro-source --no-federated
gbrain sync --source repro --repo /tmp/repro-source
gbrain embed --all
gbrain stats # confirms 3 pages, 3 chunks, 3 embedded
# THE BUG: results print instantly, process never exits
gbrain search "fox" --source repro -n 3 &
PID=$!
sleep 30
kill $PID # still running after 30s despite results printed in <2s
Observed Behavior
Results print correctly within 1-2 seconds:
[0.2432] one -- The quick brown fox jumps over the lazy dog. Pangram test.
[0.2432] three -- Brown fox testing. Outbox approval queue.
But the process never exits. It sits at ~27% CPU with no observable network traffic. Must be killed externally.
Same behavior with:
gbrain search "HMAC" --source repro -n 3
gbrain query "pangram" --source repro -n 3 --no-expand
- All search modes (conservative, balanced, tokenmax)
- Tested on both 3-page fresh brain and 91-page production brain
What works fine
gbrain stats — instant
gbrain list --source sam-persona -n 5 — instant
gbrain doctor — completes in ~30s, embedding probe shows openai:text-embedding-3-small ✓ 553ms
gbrain embed --all — completes normally
gbrain sync — completes normally
Hypothesis
The search results are produced correctly, so the vector similarity query and result formatting work. The hang appears to be in process cleanup/shutdown — possibly the PGLite WASM runtime not releasing, a dangling event loop handle, or an unclosed connection pool preventing Node/Bun from exiting.
Doctor output
Health score: 25 (production brain with 91 pages, 348 chunks, 348/348 embedded).
Full gbrain doctor --json available on request.
Workaround
Wrapping calls with a background kill timer:
gbrain search "query" --source src -n 5 &
PID=$!; ( sleep 30; kill $PID 2>/dev/null ) &; wait $PID
This captures the stdout results before the timer kills the hung process.
Summary
gbrain searchandgbrain queryprint correct results but the process never exits on PGLite. The search logic itself works — results appear within 1-2 seconds — but the bun process hangs at ~27% CPU indefinitely until killed. This affects both the production brain (91 pages) and a minimal 3-page repro.Environment
54a0629, upgraded from772253e— same behavior on both)openai:text-embedding-3-small(1536d)conservative,tokenmax, andbalanced— all hangMinimal Reproduction
Observed Behavior
Results print correctly within 1-2 seconds:
But the process never exits. It sits at ~27% CPU with no observable network traffic. Must be killed externally.
Same behavior with:
gbrain search "HMAC" --source repro -n 3gbrain query "pangram" --source repro -n 3 --no-expandWhat works fine
gbrain stats— instantgbrain list --source sam-persona -n 5— instantgbrain doctor— completes in ~30s, embedding probe showsopenai:text-embedding-3-small ✓ 553msgbrain embed --all— completes normallygbrain sync— completes normallyHypothesis
The search results are produced correctly, so the vector similarity query and result formatting work. The hang appears to be in process cleanup/shutdown — possibly the PGLite WASM runtime not releasing, a dangling event loop handle, or an unclosed connection pool preventing Node/Bun from exiting.
Doctor output
Health score: 25 (production brain with 91 pages, 348 chunks, 348/348 embedded).
Full
gbrain doctor --jsonavailable on request.Workaround
Wrapping calls with a background kill timer:
This captures the stdout results before the timer kills the hung process.