plugins-workspace: [bug] tauri_plugin_log with TargetKind::Webview causes infinite log loop

Describe the bug

When using the tauri_plugin_log plugin with the Webview target as such

        .plugin(
            tauri_plugin_log::Builder::new()
                .targets([Target::new(TargetKind::Stdout), Target::new(TargetKind::Webview)])
                .level(LevelFilter::Info)
                .build(),
        )

I get an infinite stream of

[2024-12-03][07:20:30][tauri::manager][INFO] app::emit; event="log://log"
[2024-12-03][07:20:30][tauri::manager][INFO] app::emit; event="log://log"
[2024-12-03][07:20:30][tauri::manager][INFO] app::emit; event="log://log"
[2024-12-03][07:20:30][tauri::manager][INFO] app::emit; event="log://log"
[2024-12-03][07:20:30][tauri::manager][INFO] app::emit; event="log://log"
[2024-12-03][07:20:30][tauri::manager][INFO] app::emit; event="log://log"
[2024-12-03][07:20:30][tauri::manager][INFO] app::emit; event="log://log"
[2024-12-03][07:20:30][tauri::manager][INFO] app::emit; event="log://log"
[2024-12-03][07:20:30][tauri::manager][INFO] app::emit; event="log://log"
...

This is likely caused by the emit event handler emitting a lot which in turn calls the WebView target handler which calls emit etc…

I’m not sure if there’s any config I’m supposed to have set to pre-filter that log message. Either one would need to avoid emit creating any log messages or try to manually not trigger emit on such messages for WebView targets.

Reproduction

No response

Expected behavior

No response

Full tauri info output

cargo tauri info
WARNING: no lock files found, defaulting to npm

[✔] Environment
    - OS: Mac OS 15.1.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.82.0-nightly (28a58f2fa 2024-07-31)
    ✔ cargo: 1.82.0-nightly (257b72b8a 2024-07-30)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: nightly-aarch64-apple-darwin (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.10.0
    - yarn: 1.22.19
    - npm: 10.2.4

[-] Packages
    - tauri [RUST]: 2.1.1
    - tauri-build [RUST]: 2.0.3
    - wry [RUST]: 0.47.2
    - tao [RUST]: 0.30.8
    - tauri-cli [RUST]: 2.0.0-beta.20
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 2.0.0-beta.20 (outdated, latest: 2.1.0)

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/

[-] iOS
    - Developer Teams: ...

Stack trace

No response

Additional context

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (13 by maintainers)

Most upvoted comments

Do you mind just copy the string in so I can see the full thing? I think the problems is probably @tauri-apps also contains an @

"@http://localhost:1420/node_modules/.vite/deps/@tauri-apps_plugin-log.js:50:47
log@http://localhost:1420/node_modules/.vite/deps/@tauri-apps_plugin-log.js:49:20
@http://localhost:1420/node_modules/.vite/deps/@tauri-apps_plugin-log.js:62:12
error@http://localhost:1420/node_modules/.vite/deps/@tauri-apps_plugin-log.js:61:22
@http://localhost:1420/src/App.tsx:83:10"

@ayangweb well, I think this is another bug, probably you’re logging uncaught errors and the log itself threw, I will open a fix for that right now

Thanks for taking a look! I’ll try see if I can reproduce it in a new tauri app.