Skip to content

Fix errors from immediately ready async callbacks - #5892

Open
tianrking wants to merge 1 commit into
DioxusLabs:mainfrom
tianrking:codex/core-ready-async-callback-errors
Open

tianrking wants to merge 1 commit into
DioxusLabs:mainfrom
tianrking:codex/core-ready-async-callback-errors

Conversation

@tianrking

Copy link
Copy Markdown

An async callback that returns Err on its first poll currently loses that error: AsyncResultMarker only forwards errors after a Pending result. For example, Callback::new(|()| async { Err(error) }) never reaches its error boundary, while yielding before the same error does.

Handle both ready outcomes explicitly. A ready error goes through the existing synchronous callback scope and throw_error path to its error boundary; only pending futures are spawned and resumed through the existing path. The initial synchronous poll remains so event handlers can still call prevent_default during the event tick. No public API changes.

Six regression tests cover ready/pending errors for Callback and ListenerCallback, callback scope, synchronous and deferred event effects, successful results preserving an existing error, and the nearest ErrorBoundary rendering its fallback.

Validation on native Windows MSVC with Rust 1.98.1, one Cargo job and one test thread:

  • Before the fix: the three ready-error tests fail; the three pending/success controls pass. After the fix: all six pass, including a final rerun after restoring the fixed source.
  • cargo test --locked -p dioxus-core --lib --tests -- --test-threads=1: 143 passed.
  • cargo test --locked -p dioxus-core --doc -- --test-threads=1: 69 passed, 7 ignored.
  • cargo fmt -p dioxus-core --check and git diff --check: passed. Whole-workspace formatting could not run on this Windows host because its command exceeded the Windows command-length limit (error 206).
  • Strict core Clippy with -D warnings fails on untouched dependency code under this toolchain: useless_borrows_in_formatting in core-macro; allowing that lint then exposes map_or_identity in html. Both were reproduced against the original production source. cargo clippy --locked -p dioxus-core --lib --tests -- -D warnings -A clippy::useless_borrows_in_formatting -A clippy::map_or_identity passes. No lint configuration or unrelated source was changed. Repository CI uses its own pinned toolchains and has not yet been verified for this PR.

AI assistance was used to investigate the source, implement the fix, and prepare regression tests. The reported results were verified in the local native environment.

This branch has not been deployed

No deployments
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