Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Pass stream errors through to callbacks #899

Closed
insipx opened this issue Jul 11, 2024 · 0 comments · Fixed by #1182 · May be fixed by #1163
Closed

Feature request: Pass stream errors through to callbacks #899

insipx opened this issue Jul 11, 2024 · 0 comments · Fixed by #1182 · May be fixed by #1163
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@insipx
Copy link
Contributor

insipx commented Jul 11, 2024

This should make handling stream errors possible from the SDK's

Need a good way to pass a Result<> through the FFI boundary for uniffi & napi. This could either be by using the traditional Result type or crafting some custom type for XMTP Stream errors.

the fn signatures in question:
pub async fn stream_conversations
pub(crate) async fn stream_messages
pub async fn stream_all_messages
pub fn stream_conversations_with_callback
pub(crate) fn stream_messages_with_callback
pub fn stream_all_messages_with_callback

the with_callback variant is just the non-with-callback variant, except they take a callback and iterate on the stream in a spawned tokio task. This makes it more ergonomic for native client sdks to use the stream, since these native SDK's have no notion of a rust Stream type.

Notice, that in the with_callback variants, instead of passing the error into the callback, we instead match on the result and log an error. This makes it difficult/impossible for external SDKs to handle stream errors. we need a way to pass the error into the callback that is compatible with uniffi and napi

these bindings are in bindings_node/ and bindings_ffi/ folders respectively.

This will allow external native SDK's to handle stream errors rather than silently failing if an error occurs in a stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Done
1 participant