Skip to content

Fix/caller disconnect callee crash#2151

Closed
markope wants to merge 2 commits intocrossbario:masterfrom
RecordEvolution:fix/caller-disconnect-callee-crash
Closed

Fix/caller disconnect callee crash#2151
markope wants to merge 2 commits intocrossbario:masterfrom
RecordEvolution:fix/caller-disconnect-callee-crash

Conversation

@markope
Copy link
Contributor

@markope markope commented Dec 31, 2025

Fix: Prevent callee session crash when caller disconnects during RPC

Description

This PR fixes a bug where the callee's session crashes when the caller disconnects during an in-flight RPC call.

Problem

When a WAMP caller disconnects while waiting for an RPC response (e.g., browser page reload), the callee receives an exception and its session is terminated. This happens because:

  1. The router checks if the callee supports call_canceling
  2. If not supported, it skips cleanup entirely (continue)
  3. Stale invocation tracking data remains in memory
  4. When callee returns a result, it finds the caller's transport is None
  5. This causes an error that crashes the callee's session

Solution

Always clean up invocation tracking when caller disconnects, regardless of call_canceling support:

# BEFORE (buggy): Skip cleanup if callee doesn't support canceling
if not callee_supports_call_canceling:
    continue  # BUG: leaves stale invocation tracked!

# AFTER (fixed): Always clean up, conditionally send INTERRUPT  
cleanup_invocation_tracking()  # Always executed
if callee_supports_call_canceling:
    send_interrupt()  # Only if supported

Changes

  • File: src/crossbar/router/dealer.py
  • Method: Dealer.detach()
  • Moved cleanup code before the call_canceling check
  • INTERRUPT message is still only sent if callee supports it
  • Added clarifying log message for non-canceling case

Impact

  • Callees without call_canceling: No longer crash when caller disconnects; they complete normally and the result is silently discarded
  • Callees with call_canceling: Behavior unchanged (receive INTERRUPT as before)
  • Backward compatible: No breaking changes

Testing

  • New test: test_caller_detach_cleans_up_invocation_tracking_without_cancel_support
    • Verifies invocation tracking is cleaned up when caller disconnects
    • Callee without call_canceling support
    • Confirms callee can return result without crash (result silently discarded)

Existing tests cover related scenarios:

  • test_caller_detach_interrupt_cancel_not_supported
  • test_caller_detach_interrupt_cancel_supported

Fixes

#2133

Marko Petzold added 2 commits December 31, 2025 13:01
When a caller disconnects while an RPC is in-flight, the router must
clean up invocation tracking regardless of whether the callee supports
call canceling. Previously, the cleanup was skipped if the callee
didn't support call_canceling, leaving stale data structures that
caused errors when the callee tried to return a result.

The fix:
- Always clean up invocation tracking (timeout, data structures)
- Only send INTERRUPT message if callee supports call_canceling
- Log appropriately in both cases

Fixes: crossbario#2133
@markope markope closed this Jan 3, 2026
@markope markope deleted the fix/caller-disconnect-callee-crash branch January 3, 2026 14:56
@markope
Copy link
Contributor Author

markope commented Jan 3, 2026

closed and replaced by #2153 due to process reasons

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