Fix event loop blocking and add database timeouts#9
Merged
drewburchfield merged 4 commits intomasterfrom Apr 3, 2026
Merged
Conversation
- Make embed_batch() and embed() async, route API calls through _call_api_with_timeout() to avoid blocking the event loop with synchronous time.sleep() backoff - Add _with_timeout() helper to VectorStore and wrap all pool operations with appropriate timeouts (5s for reads, 10s for writes, 30s for batch operations) - Add error handling for symlink resolution failures in security_utils.py path validation - Replace deprecated asyncio.get_event_loop() with asyncio.get_running_loop() in embedder.py and server.py - Update all callers of embed()/embed_batch() to use await (server.py, diagnose_vault.py)
… mocks - Make embed_with_chunks() async with await on embed() and _call_api_with_timeout() - Add await to callers in file_watcher.py and indexer.py - Switch test mocks from MagicMock to AsyncMock for embed/embed_batch/embed_with_chunks - Add await to integration test embed calls in test_tools.py and test_mcp_tools_integration.py
Comment on lines
+53
to
+54
| problematic_files.append((rel_path, str(e))) | ||
| print(f"[{i}/{len(md_files)}] ERROR: {rel_path} - {e}") |
There was a problem hiding this comment.
🟡 rel_path used before assignment in outer exception handler
If open(file_path) at line 28 or f.read() at line 29 throws an exception, execution jumps to the outer except Exception at line 52. At that point, rel_path (assigned at line 31) has not been defined yet. On the first loop iteration this causes a NameError, crashing the diagnostic tool. On subsequent iterations, rel_path retains the value from the previous iteration, silently attributing the error to the wrong file.
Suggested change
| problematic_files.append((rel_path, str(e))) | |
| print(f"[{i}/{len(md_files)}] ERROR: {rel_path} - {e}") | |
| rel_path = str(file_path.relative_to(vault_path)) if vault_path in file_path.parents or file_path.parent == vault_path else str(file_path) | |
| problematic_files.append((rel_path, str(e))) | |
| print(f"[{i}/{len(md_files)}] ERROR: {rel_path} - {e}") |
Was this helpful? React with 👍 or 👎 to provide feedback.
drewburchfield
added a commit
that referenced
this pull request
Apr 3, 2026
…ng table - diagnose_vault.py: compute rel_path before try block to avoid NameError when file open/read fails (Devin PR #9) - schema.sql: move DROP TRIGGER after CREATE TABLE so fresh databases don't fail on non-existent table (Devin PR #10) - vector_store.py: guard DROP TRIGGER migration behind table_exists check to prevent initialize() failure on fresh databases (Devin PR #10)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes NAS-394
Summary
Test plan