Skip to content

[bug] tauri_plugin_log with TargetKind::Webview causes infinite log loop #2126

Open
@tdomhan

Description

@tdomhan

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions