window.__TAURI__.dialog causes app to freeze (sometimes)

I have a small Tauri GUI app. I e.g have a button to delete a file:

async function deleteFile(filename) {
    try {
        await invoke("delete_file", { filename });
        await message("File deleted.");
    } catch (error) {
        await message(error);
    }
}

It is called like this:

            deleteButton.addEventListener("click", () => {
                deleteFile(filename);
            });

When having await message("File deleted."); in the code, the app just freezes with no console.log message or Rust-error. It only freezes most of the time. If I restart my laptop and run it the first time after restart, the messages work.

Why is this?

Sounds like a deadlock I'm afraid!

Is there a Mutex or RwLock involved? That's where I would start looking.

It might be an infinite loop if there is no locking going on.

My code is here: Project time logger (Tauri GUI)

But how can it be a deadlock? The Rust code works without that one line in JS

Oh message() comes from Tauri dialog module.

I'm not sure why it isn't working, it could be a bug in Tauri I suppose. Is it opening a dialog and displaying a message?

The fact that rebooting your laptop can make it work suggests that something weird is going on.

The fact that it freezes without any error messages suggests it's stuck during execution and not making any progress, which is why it sounded like a deadlock or infinite loop.

1 Like

It is not showing any message-box at all.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.