Skip to content

Fix showToast not displaying error message#9473

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/fix-showtoast-error-message
Draft

Fix showToast not displaying error message#9473
Copilot wants to merge 1 commit into
mainfrom
copilot/fix-showtoast-error-message

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

Summary

showToast was turning red on errors but not showing the error message text.

Root Cause

updateToast() — the function that updates the message text in the DOM — was called only as the first statement of finalUpdateToast(), an async function invoked fire-and-forget via void in the finally block:

} finally {
    void finalUpdateToast(finalToastMessage || lastRawMessage); // updateToast was inside here
}

When throw error is pending from the catch block, the DOM update initiated inside the fire-and-forget async task can fail to render before the error propagates and the caller's code runs. In browser extension environments particularly, this means the message wrapper gets cleared (by messageWrapper.textContent = '') but never repopulated.

Fix

Move updateToast() out of finalUpdateToast() and call it synchronously in the finally block before starting the async animation work:

} finally {
    const toastMessage = finalToastMessage || lastRawMessage;
    updateToast(toastMessage);          // ← guaranteed synchronous DOM update
    void finalUpdateToast(toastMessage); // ← async: handles timing + animation only
}

This guarantees the message wrapper is always updated synchronously during finally execution, regardless of error propagation behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants