-
Notifications
You must be signed in to change notification settings - Fork 732
fix: handle EAGAIN when reading hook stdin in non-blocking mode #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,15 @@ const ROOT_DIR = path.resolve(SCRIPT_DIR, ".."); | |
| const STOP_REVIEW_TASK_MARKER = "Run a stop-gate review of the previous Claude turn."; | ||
|
|
||
| function readHookInput() { | ||
| const raw = fs.readFileSync(0, "utf8").trim(); | ||
| let raw; | ||
| try { | ||
| raw = fs.readFileSync(0, "utf8").trim(); | ||
| } catch (e) { | ||
| if (e.code === "EAGAIN") { | ||
| return {}; | ||
| } | ||
|
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with πΒ / π. |
||
| throw e; | ||
| } | ||
| if (!raw) { | ||
| return {}; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling
EAGAINby returning{}causes this lifecycle hook to proceed as if no event data was provided, even though a non-blocking read may succeed moments later. InSessionEnd, that can losesession_id/cwdcontext and skip targeted cleanup (cleanupSessionJobs) or cleanup the wrong scope. The read path should retry onEAGAINrather than converting it to empty input.Useful? React with πΒ / π.