fix: keep bounded event consume runs alive after stdin EOF#1285
Conversation
📝 WalkthroughWalkthroughThis PR refines stdin EOF shutdown behavior for the ChangesConditional stdin EOF watching for bounded event consumption runs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@687a3b8b82485f2f1f46448f5f82c4ae89616e6b🧩 Skill updatenpx skills add larksuite/cli#fix/event-consume-stdin-eof -y -g |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1285 +/- ##
=======================================
Coverage 71.42% 71.43%
=======================================
Files 688 688
Lines 65313 65318 +5
=======================================
+ Hits 46653 46658 +5
Misses 15021 15021
Partials 3639 3639 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
37d2dc3 to
687a3b8
Compare
Summary
event consumearmed its stdin-EOF shutdown watcher for every non-TTY session, so subprocess callers whose stdin is/dev/null(OpenCode, CI,bash -c) were cancelled at startup withError: context canceled— even when--max-events/--timeoutexplicitly declared the run's lifecycle (#1131). This PR gates the watcher to non-TTY unbounded runs only, so bounded runs exit via their own bound, timeout, or SIGTERM. Supersedes #1183 (cherry-picked with author attribution preserved) and adds the documentation/contract sync it lacked.Changes
shouldWatchStdinEOF(non-TTY &&maxEvents <= 0&&timeout <= 0) incmd/event/consume.go— cherry-picked from fix(event): keep bounded consume alive after stdin EOF #1183 (author @jinhyuk9714)TestShouldWatchStdinEOFwith combined / mixed-sign bound cases incmd/event/consume_stdin_test.go(9 cases total)internal/event/consume/consume.go, with tests ininternal/event/consume/listening_text_test.goskills/lark-event/SKILL.md: bounded-run stdin-EOF exemption and exit-reason table note--max-events/--timeoutflag help incmd/event/consume.goBehavior change: a bounded run no longer stops early when a piped stdin closes — it exits only via its bound, timeout, or SIGTERM. Residual (accepted): unbounded runs over
/dev/nullkeep the documented legacy instant graceful exit (reason: signal); under a cold-start race this can surface as exit 1context canceled(pre-existing, out of scope).Test Plan
make unit-testpassed (full unit + integration suite, via harness validate)lark-cli event consume im.message.receive_v1 --as bot --max-events 1 --timeout 10m < /dev/nullin the sandbox container — stayed alive 5m07s on/dev/nullstdin, received 1 real IM event, exited 0 withreason: limitRelated Issues
Closes #1131
Supersedes #1183 (commits cherry-picked with original authorship preserved).