Skip to content

Commit d98497e

Browse files
phernandezclaude
andcommitted
fix: disable file sync in integration tests to prevent hanging
The MCP server lifespan starts a background file sync task when sync_changes=True (the default). This task runs indefinitely, causing integration tests to hang. Fix: Set sync_changes=False in the test app_config fixture. This is the proper solution because: - It's test configuration, not production code hacking - Integration tests don't need file sync - they test MCP tools/API - The lifespan works correctly, it just won't start the blocking task Also includes minor formatting cleanup in app.py. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 554c3d7 commit d98497e

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/basic_memory/cli/app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ def app_callback(
3838
# Skip for 'mcp' command - it has its own lifespan that handles initialization
3939
# Skip for API-using commands (status, sync, etc.) - they handle initialization via deps.py
4040
api_commands = {"mcp", "status", "sync", "project", "tools"}
41-
if not version and ctx.invoked_subcommand is not None and ctx.invoked_subcommand not in api_commands:
41+
if (
42+
not version
43+
and ctx.invoked_subcommand is not None
44+
and ctx.invoked_subcommand not in api_commands
45+
):
4246
from basic_memory.services.initialization import ensure_initialization
4347

4448
app_config = ConfigManager().config

test-int/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ def app_config(
236236
default_project_mode=False, # Match real-world usage - tools must pass explicit project
237237
update_permalinks_on_move=True,
238238
cloud_mode=False, # Explicitly disable cloud mode
239+
sync_changes=False, # Disable file sync in tests - prevents lifespan from starting blocking task
239240
database_backend=database_backend,
240241
database_url=database_url,
241242
)

test-int/mcp/test_lifespan_shutdown_sync_task_cancellation_integration.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,3 @@ async def _run_client_once():
6666
# Use asyncio.run to match the CLI/MCP execution model where loop teardown
6767
# would hang if a background task is left running.
6868
asyncio.run(_run_client_once())
69-
70-

0 commit comments

Comments
 (0)