fix(core): allow RPC handler registration after connect#61
Merged
Conversation
Registering an RPC handler on a live LocalParticipant triggers SDK publisher negotiation, which `tokio::spawn`s internally. When `register_rpc_method` is called from a foreign thread with no runtime context (a binding's asyncio loop), that spawn panicked with "there is no reactor running, must be called from the context of a Tokio 1.x runtime". Capture the runtime handle `connect()` runs on and enter it around the live-registration call so the spawn lands on that runtime. Pre-connect registration was unaffected (handlers are applied inside connect, which already runs on the runtime). Fixes #59
Adds integration coverage for the post-connect registration regression (previously panicked), the pre-connect path, and handler error propagation.
ladvoc
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #59.
Problem
Registering a foreign async RPC handler after
connect()panicked:The SDK's
register_rpc_methodcallspublisher_negotiation_needed(), whichtokio::spawns. WhenPortal::register_rpc_methodruns on a live participant from a foreign thread (a binding's asyncio loop, no runtime context), that spawn panics.Fix
Capture the tokio runtime handle that
connect()runs on, and enter it around the liveregister_handler_oncall so the internal spawn lands on that runtime. Pre-connect registration was already fine (handlers are applied insideconnect(), which runs on the runtime).Tests
New
tests/integration/test_rpc.py:test_rpc_register_after_connect— the regression guard (previously panicked)test_rpc_register_before_connect— pre-connect path still workstest_rpc_handler_error_propagates— application errors surface on the callerVerification
cargo clippy --workspace -- -D warningscleancargo fmt --checkcleancargo test --workspace --locked— 96 passedpytest— 47 passedIndependent of #58 (role-split bindings); branched from
main.