fix: inject tokio runtime handle into sync watch* spawn#281
Open
dignifiedquire wants to merge 2 commits into
Open
fix: inject tokio runtime handle into sync watch* spawn#281dignifiedquire wants to merge 2 commits into
dignifiedquire wants to merge 2 commits into
Conversation
The sync watch_* registration methods spawn a background task via tokio::spawn, but they run on the foreign caller's thread with no tokio Handle in TLS — causing 'no reactor running' panics that abort the JS host process and surface as uniffi InternalException. - JS: spawn via napi::bindgen_prelude::spawn, which uses napi's own global tokio runtime — no state threading needed. - Uniffi: capture Handle::current() at Endpoint / Connection construction (all callers are async fns wrapped by async_compat) and pass it to the spawn helpers. Both approaches keep the sync fire-and-forget API — the fn signature does not become async.
Register + stop each watch_* method — before the runtime-handle fix these panicked with 'no reactor running', aborting the JS host and surfacing as InternalException on Python/Kotlin/Swift. Coverage: Rust (std::thread — reproduces the FFI thread condition), JS (node:test), Python (pytest), Kotlin (JUnit), Swift (XCTest).
dignifiedquire
force-pushed
the
fix/watch-async
branch
from
July 20, 2026 11:05
1c0c8dd to
3a5d67f
Compare
|
Reviewed — routing the watcher spawns through the runtime handle resolves the panic at its actual root (spawn-time ambient-runtime assumption), and fixing it in the shared core rather than per-binding is the right call: we'd reproduced the failure on three surfaces (napi aborts the process, Kotlin surfaces InternalException), and the test additions cover all of them plus Python. Once released we can retire our poll-only workaround and get push semantics back for relay/path status — which we currently approximate with heartbeat timeouts. Looks good, thank you! |
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.
Closes #277