Repository navigation
fix(memory): detach SessionEnd index so the hook can't be "Hook cancelled" - #191
Closed
sandstream wants to merge 1 commit into
Closed
sandstream wants to merge 1 commit into
sandstream wants to merge 1 commit into
Conversation
…lled" The session-end hook ran runSessionEndIndex() inline; on a periodic all-harness sweep (indexAllHarnesses over opencode/cursor/codex/gemini/…) — or a hung opt-in push_on_end — it could overrun Claude Code's shutdown window and surface as "SessionEnd hook … failed: Hook cancelled". - Common path (no push_on_end): detach the index into a fire-and-forget child (spawnDetachedIndex, mirroring the mid-session debounce) so the hook returns instantly. The index still completes; next SessionStart recovery re-indexes any missed tail. - Ephemeral path (push_on_end = true): keep indexing inline so the push observes this session's rows before the container is reclaimed — gated by the new isAutoPushConfigured(). Fail-open throughout. 3 new tests (isAutoPushConfigured: unconfigured/no-flag → false, push_on_end → true, malformed config → fail-safe false). Suite 1984 green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Owner
Author
|
Closing as a duplicate — #190 already merged the same fix and is the better version. #190 detaches the entire SessionEnd worker (index and the opt-in push) via an internal Nothing here to salvage. Closing. Generated by Claude Code |
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.
What
kit memory hook session-endcould surface as:(observed live in a real Claude Code session.)
Why
The hook ran its work inline:
runSessionEndIndex()followed by an opt-intryAutoPush(). On most exits the index is a fast Claude-Code-only pass, but on a periodic all-harness sweep it callsindexAllHarnesses()(walks opencode/cursor/codex/gemini/… stores), and an enabledpush_on_endadds an encrypt-and-push. Either can overrun Claude Code's SessionEnd shutdown window, and Claude Code then cancels the still-running hook. It's fail-soft (no corruption; the next SessionStart recovery re-indexes the tail) — just noisy.Fix
Branch the session-end handler on whether a push is actually configured:
push_on_end) — detach the index into a fire-and-forget child (spawnDetachedIndex, the same trick the mid-session debounce already uses) and return immediately. Nothing for Claude Code to cancel; the index still completes in the background.push_on_end = true) — keep indexing inline so the push observes this session's freshly-indexed rows before the container is reclaimed. Gated by a new cheap, fail-safeisAutoPushConfigured().Fail-open throughout (a session is never blocked on exit).
Tests
3 new tests for
isAutoPushConfigured(unconfigured / configured-without-flag →false;push_on_end = true→true; malformed config → fail-safefalse, so a bad config never forces an inline push). Full suite 1984 green, prettier clean.🤖 Generated with Claude Code
https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Generated by Claude Code