Skip to content

Chat parse error alert shows the stack trace in the alert body #1653

Open

Description

@SameDesu123

What happens

When a chat message fails to parse three times in a row, the error alert prints the whole stack trace in the alert body:

Error while parsing chat message: true, Failed to fetch, TypeError: Failed to fetch
    at jz (http://tauri.localhost/assets/database.svelte-6wcmeoV8.js:2210:1862)
    at Az (http://tauri.localhost/assets/database.svelte-6wcmeoV8.js:2209:349)
    ...
This happens when the network is unstable or the server is down.

The alert body is meant for a short error message. Stacks are supposed to go to the "Show error details" panel, which also translates them with source maps and has a copy button. That panel does not appear for this error.

The message also contains a stray true, (or false,), which means nothing to the user.

Cause

markParsing in src/lib/ChatScreens/ChatBody.svelte calls alertError with one string:

alertError(`Error while parsing chat message: ${translated}, ${error.message}, ${error.stack}`)

alertError (src/ts/alert.ts) only moves the stack into stackTrace when it receives an Error. A string goes into msg as is, so the stack ends up in the body and stackTrace stays empty. The true, is the component's translated flag.

Suggested fix

Wrap the message in a new Error, copy the original stack onto it, pass that Error to alertError, and drop translated from the message.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions