Skip to content

fix: bound publish_interaction so a hung Windows backend can't freeze the SessionStart hook#117

Open
smoochy wants to merge 2 commits into
ReflexioAI:mainfrom
smoochy:fix/issue-109-publish-hang-containment
Open

fix: bound publish_interaction so a hung Windows backend can't freeze the SessionStart hook#117
smoochy wants to merge 2 commits into
ReflexioAI:mainfrom
smoochy:fix/issue-109-publish-hang-containment

Conversation

@smoochy

@smoochy smoochy commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Containment for #109 (root cause tracked in ReflexioAI/reflexio: ReflexioAI/reflexio#295). Runs the publish under an 8s wall-clock cap; on timeout returns False and the unpublished buffer retries next turn. Refs #109.

Summary by CodeRabbit

  • Bug Fixes
    • publish now enforces a short wall-clock timeout for send operations, so the app won’t hang if delivery stalls.
    • If publishing doesn’t complete within the timeout, the attempt is treated as failed to allow buffering/retries instead of blocking.
  • Tests
    • Added a regression test to verify fail-fast behavior when the underlying publish call hangs and completes within a bounded time.

…eze the hook

Client-side containment for the Windows publish hang (ReflexioAI/reflexio root cause).
Refs ReflexioAI#109
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 90852ae2-1888-4169-89d0-360375804acf

📥 Commits

Reviewing files that changed from the base of the PR and between 87b8654 and 1dd6582.

📒 Files selected for processing (1)
  • plugin/src/claude_smart/reflexio_adapter.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugin/src/claude_smart/reflexio_adapter.py

📝 Walkthrough

Walkthrough

Adapter.publish now runs client.publish_interaction in a background daemon thread with a wall-clock join timeout and returns False on timeout instead of blocking indefinitely. A regression test covers the hanging-client case.

Changes

Publish Timeout Enforcement

Layer / File(s) Summary
Threaded publish with timeout
plugin/src/claude_smart/reflexio_adapter.py
Adds threading support, defines _PUBLISH_WALL_TIMEOUT_SECONDS, and changes Adapter.publish to join a daemon thread around client.publish_interaction, returning False when the timeout is exceeded or when the call fails.
Hanging client regression test
tests/test_adapter.py
Adds a regression test that simulates a stalled client, shortens the timeout, and asserts publish() returns False quickly without crashing.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant AdapterPublish as Adapter.publish
  participant Thread as Daemon Thread
  participant Client as Reflexio Client

  Caller->>AdapterPublish: publish(kwargs)
  AdapterPublish->>Thread: start(client.publish_interaction, kwargs)
  AdapterPublish->>Thread: join(_PUBLISH_WALL_TIMEOUT_SECONDS)
  alt Thread finishes in time
    Thread->>Client: publish_interaction(**kwargs)
    Thread-->>AdapterPublish: success flag
    AdapterPublish-->>Caller: return success
  else Thread still alive after timeout
    AdapterPublish-->>Caller: log warning, return False
  end
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: bounding publish_interaction to prevent a hung Windows backend from freezing the SessionStart hook.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugin/src/claude_smart/reflexio_adapter.py`:
- Around line 130-146: The exception handling around publish_interaction is no
longer covering failures once _do_publish runs in the background thread. Update
the Reflexio adapter’s _do_publish helper in reflexio_adapter.py to catch
exceptions from client.publish_interaction(**kwargs) inside the worker thread,
log or record the failure, and ensure the thread cannot emit an unhandled
traceback; keep the worker/thread timeout behavior and only set result["ok"]
after a successful publish.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4898f321-6742-4c56-a7fd-cb1b894a74e7

📥 Commits

Reviewing files that changed from the base of the PR and between 69fccb0 and 87b8654.

📒 Files selected for processing (2)
  • plugin/src/claude_smart/reflexio_adapter.py
  • tests/test_adapter.py

Comment thread plugin/src/claude_smart/reflexio_adapter.py Outdated
fix: contain publish exceptions raised inside the worker thread

The wall-clock guard ran publish_interaction in a background thread, but the
outer try/except cannot catch exceptions raised there — a connection failure
emitted an unhandled thread traceback instead of being contained. Capture the
exception in the worker, then surface it as a warning + False after join.

Addresses CodeRabbit review on ReflexioAI#117.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@
@smoochy

smoochy commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review — addressed in 1dd6582: the publish now runs under a try/except inside the worker thread, and a captured exception is surfaced as a warning + False after join, so a connection failure is contained instead of leaking a thread traceback.

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