Skip to content

fix: the pick_file() can return None when cancelled#258

Merged
PolyMeilex merged 4 commits intoPolyMeilex:masterfrom
bioinformatist:fix/cancel_button
Jul 16, 2025
Merged

fix: the pick_file() can return None when cancelled#258
PolyMeilex merged 4 commits intoPolyMeilex:masterfrom
bioinformatist:fix/cancel_button

Conversation

@bioinformatist
Copy link
Contributor

Hey dude,

I feel apologetic for such a slipup.

In my earlier PR #252, the overlay was removed directly from the body, which left the JavaScript Promise unresolved, breaking the event loop during .await and preventing the correct return value None from being obtained from pick_file().

To address this issue, the Promise will now be rejected if cancelled. Since the current show() does not permit failure, I am marking the future result with .ok() instead of .unwrap(). Hope it's good enough this time 😅

@bioinformatist
Copy link
Contributor Author

The way I used for debugging is to add dependencies in Cargo.toml:

console_error_panic_hook = "0.1"
console_log = "1.0"
log = "0.4"

Also register the hook in main.rs:

console_log::init().expect("Initialize logger");
std::panic::set_hook(Box::new(console_error_panic_hook::hook));

Do you think it's necessary for adding these into main branch?

Finally in the winit-example, if the F pressed and then cancelled, the console will display None, while with #252 nothing happens.

@PolyMeilex PolyMeilex merged commit 9fff513 into PolyMeilex:master Jul 16, 2025
13 checks passed
@PolyMeilex
Copy link
Owner

Thanks!

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.

2 participants