Repository navigation
fix(hooks): give SessionEnd a timeout so shutdown does not cancel it - #101
Open
overkamperic wants to merge 1 commit into
Open
overkamperic wants to merge 1 commit into
overkamperic wants to merge 1 commit into
Conversation
SessionEnd hooks share a 1.5 s budget unless a hook sets its own timeout (Claude Code raises the budget to match, up to 60 s). The hook needs about 1.3-1.6 s to start through uv on native Windows, so it is cancelled on every exit and the session's held-back final turn is never exported. See langfuse#13.
|
|
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.
Relates to #13.
Problem
On native Windows the
SessionEndhook is cancelled on every exit (failed: Hook cancelled), and since the final turn is held back untilSessionEnd, that turn is never exported. v1.2.0's lazy-import fast path does not avoid it here: starting the hook throughuv run --scriptalone takes about 1.3 s, which together with the processing time exceeds the shared 1.5 sSessionEndwindow.The hooks reference documents the fix:
SessionEndhooks share a 1.5-second budget, and if a hook sets a longertimeout, Claude Code raises the budget to match (up to 60 s). This PR sets"timeout": 10on theSessionEndhook only.Stopis unchanged.Evidence
Environment: Windows 11, Claude Code 2.1.285, uv 0.12.15 (d35f1f270 2026-09-15 x86_64-pc-windows-msvc), plugin 1.2.0, self-hosted Langfuse. Each run was a fresh one-turn
claude -psession.Processed 0 turns)"timeout": 10Processed 1 turnsabout 4 s after exit)The same before/after held on 1.1.0: cancelled without the timeout, clean with it. User settings also had another
SessionEndhook withtimeout: 10, and the plugin's hook was still cancelled until the plugin's own entry set one.Checks
hooks/hooks.jsonparses; only theSessionEndentry changes.echo '{}' | uv run --script hooks/langfuse_hook.pyexits 0.