Skip to content

fix(trajectory-plugin): bound capture-hook call to avoid lost hook output - #56

Open
audip wants to merge 1 commit into
datadog-labs:mainfrom
audip:fix/hook-capture-timeout-bound
Open

fix(trajectory-plugin): bound capture-hook call to avoid lost hook output#56
audip wants to merge 1 commit into
datadog-labs:mainfrom
audip:fix/hook-capture-timeout-bound

Conversation

@audip

@audip audip commented Aug 16, 2026

Copy link
Copy Markdown

Fixes #54

capture-with-serve.sh execed trajectory capture-hook with no timeout of its own, relying entirely on Claude Code's outer hook timeout. When the shared serve daemon is busy for 20-30s+ on unrelated work (batch repairs, marker evaluation, publish retries — observed a 32s markers_session_end publish stall against OTLP), the hook gets hard-killed by the host tool and its output is discarded, regardless of how high the host tool's own timeout is raised.

This wraps the final capture-hook call in timeout/gtimeout (default 5s, overridable via TRAJECTORY_CAPTURE_HOOK_TIMEOUT_SECONDS) so a busy daemon causes a fast, clean exit 0 instead of an eventual hard kill with discarded output. If neither timeout nor gtimeout is present (stock macOS without coreutils), it falls back to the original unbounded exec, so behavior is unchanged on those systems.

Verified with bash -n and running locally against a real busy-daemon scenario without regressions.

…tput

capture-with-serve.sh execed trajectory capture-hook with no timeout of
its own, relying entirely on Claude Code's outer hook timeout. When the
shared serve daemon is busy for 20-30s+ on unrelated work (batch repairs,
marker evaluation, publish retries), the hook gets hard-killed by the
host tool and its output is discarded. Wrap the call in timeout/gtimeout
(default 5s, overridable via TRAJECTORY_CAPTURE_HOOK_TIMEOUT_SECONDS) so
it fails open instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@audip
audip requested a review from mr-lee as a code owner August 16, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code hooks (UserPromptSubmit etc.) time out and discard output when the shared serve daemon is busy for 20s+

1 participant