Skip to content

Complete async callbacks when result conversion fails - #173

Draft
chavic wants to merge 1 commit into
Uniffi-Dart:mainfrom
chavic:fix/async-callback-completion
Draft

chavic wants to merge 1 commit into
Uniffi-Dart:mainfrom
chavic:fix/async-callback-completion

Conversation

@chavic

@chavic chavic commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Following up on #163. If an async Dart callback returns 256 for a Rust u8, result conversion throws after the callback has already been marked cancelled. The catch branch then returns without notifying Rust, leaving the caller waiting.

This separates completion from cancellation and only marks completion once the result or error is ready to pass back. A failure while lowering the result can therefore complete with an error, and a cancelled callback still stays cancelled.

I've tested this through a real Rust future and directly through the generated callback. The async suite passed all 36 Dart tests, including eight new cases covering invalid results, declared and unexpected errors, cancellation, and cleanup during completion. Restoring the old ordering makes the new invalid-result test time out, so it catches the original bug. Formatting and diff checks passed too.

Callback threading remains in #161; failures while serializing the error itself and ownership rollback inside complex converters remain separate work.

Fixes #163.

@chavic
chavic force-pushed the fix/async-callback-completion branch from 41aa8df to fe9c077 Compare September 11, 2026 16:02
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.

Async callback result-conversion failures suppress native completion

1 participant