Skip to content

fix(lorectl): answer a hook at the end of its JSON, not when stdin closes - #414

Merged
hsusul merged 1 commit into
mainfrom
fix/hook-stdin-first-value
Nov 9, 2026
Merged

hsusul merged 1 commit into
mainfrom
fix/hook-stdin-first-value

Conversation

@hsusul

@hsusul hsusul commented Nov 9, 2026

Copy link
Copy Markdown
Owner

What

stdin_json in crates/lorectl/src/hook.rs parses the first JSON value from stdin (still capped at 1 MiB) instead of reading to end of file.

Why

A hook waited for stdin to close before doing anything. A parent that writes the event but keeps the pipe open, or any process that inherited the pipe's write end, held every hook until it exited, up to the plugin's 10s timeout. This is also part of why hooks_go_on_without_a_working_tree_that_does_not_answer fails when lorectl's test binaries run together: on macOS a pipe is briefly inheritable, so a sibling test's child can keep the hook's stdin open.

Test

New a_hook_answers_while_its_stdin_stays_open: writes the event, keeps the pipe open 5s, and requires the hook to exit first. It fails on main (5.87s, "the hook waited for stdin to close") and passes here. cargo test -p lorectl --no-fail-fast passes except the stuck-tree timing test, whose session-start run can still take ~6s under parallel load; that is a separate cause, under investigation.

…oses

Hooks read stdin to end of file, so a parent that kept the pipe open, or a
child that inherited its write end, held every hook until it exited (up to
the plugin's 10s timeout). The hook now parses the first JSON value.
@hsusul
hsusul merged commit 268d65b into main Nov 9, 2026
5 checks passed
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.

1 participant