Skip to content

fix(server): handle CancelledError during shutdown paths#848

Open
ZaynJarvis wants to merge 1 commit intomainfrom
fix/server-cancelled-error-handling
Open

fix(server): handle CancelledError during shutdown paths#848
ZaynJarvis wants to merge 1 commit intomainfrom
fix/server-cancelled-error-handling

Conversation

@ZaynJarvis
Copy link
Collaborator

@ZaynJarvis ZaynJarvis commented Mar 21, 2026

previous issue is Exception doesn't catch asyncio.CancelledError. so when asyncio.CancelledError happens, server crash.

import asyncio

print("MRO:", asyncio.CancelledError.__mro__)
print("issubclass(asyncio.CancelledError, Exception):", issubclass(asyncio.CancelledError, Exception))

try:
    raise asyncio.CancelledError("demo")
except Exception:
    print("caught by Exception")
except BaseException as e:
    print("not caught by Exception; caught by BaseException:", type(e).__name__, str(e))

===
MRO: (<class 'asyncio.exceptions.CancelledError'>, <class 'BaseException'>, <class 'object'>)
issubclass(asyncio.CancelledError, Exception): False
not caught by Exception; caught by BaseException: CancelledError demo

Summary

  • handle asyncio.CancelledError explicitly in shutdown-sensitive server paths
  • only downgrade dedup cancellation to a fallback when vector storage is actually closing
  • add regression tests for background commit cancellation, lifespan shutdown, and dedup/redo cancellation semantics

Testing

  • python3 -m ruff check openviking/session/memory_deduplicator.py openviking/storage/transaction/lock_manager.py openviking/server/app.py openviking/server/routers/sessions.py tests/session/test_memory_dedup_actions.py tests/transaction/test_lock_manager.py tests/test_session_task_tracking.py tests/server/test_server_health.py
  • python3 -m pytest tests/session/test_memory_dedup_actions.py tests/transaction/test_lock_manager.py tests/test_session_task_tracking.py tests/server/test_server_health.py

@github-actions
Copy link

Failed to generate code suggestions for PR

@ZaynJarvis ZaynJarvis requested a review from qin-ctx March 21, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant