Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[log][v2] When refreshing the page, the browser console will not be detach from the log stream #1000

Closed
A-kirami opened this issue Feb 27, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@A-kirami
Copy link

As the number of page refreshes increases, the number of logs in the browser console also increases accordingly. Each time a log is called, multiple logs will be printed to the browser console.

import { attachConsole, info } from '@tauri-apps/plugin-log'

(async () => {
  await attachConsole();
  info('App is ready')
})();

image

@FabianLars FabianLars added the bug Something isn't working label Feb 27, 2024
@kamiya10
Copy link

The attachConsole() returns a Promise that resolves to an unlisten function.
You will need to call it to unattach the console.

const unattachConsole = attachConsole();

// some code

unattachConsole.then(f => f());

@A-kirami
Copy link
Author

The attachConsole() returns a Promise that resolves to an unlisten function. You will need to call it to unattach the console.

const unattachConsole = attachConsole();

// some code

unattachConsole.then(f => f());

I understand this, but it will automatically detach after refreshing the page in v1, and I think v1 is a normal behavior.

@FabianLars
Copy link
Member

Hmm, i assume this is fixed by tauri-apps/tauri#8930 so we just have to update tauri to beta.8 in this repo

@martpie
Copy link

martpie commented Feb 29, 2024

I can confirm it was fixed in the latest version of Tauri. It is VERY useful, and not only for attachConsole, but any even listener where you get the cleanup function asynchronously: they are a pain to call in React as useEffect are not meant to be async.

Thank you!

FabianLars added a commit that referenced this issue Feb 29, 2024
amrbashir pushed a commit that referenced this issue Feb 29, 2024
* chore: Update tauri to beta.8

fixes #1000

* Update and rename tauri-beta.7.md to tauri-beta-8.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants