Skip to content

SessionEnd hooks need hard timeouts to prevent chain blocking #965

Description

@rolpro

Problem

SessionEnd hooks currently run sequentially without enforcement of maximum execution time. This architecture creates a critical bottleneck: if any hook in the chain hangs (due to slow stdin, unresponsive APIs, or large transcript processing), all subsequent hooks are blocked indefinitely.

This is particularly problematic for developers adding new hooks to the end of the chain. A single misbehaving hook earlier in the sequence can prevent new logic from ever executing, making the system unreliable and difficult to debug.

Suggested Fix

Implement a hard timeout safety net for each SessionEnd hook using setTimeout with a process.exit(0) fallback, ensuring clearTimeout is called on normal exit paths.

Recommended timeouts:

  • 10s for file-only hooks
  • 15s for API-calling hooks
  • 30s for inference hooks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions