tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
83.98k stars 2.52k forks source link

[bug] Missing Permission Error for WebviewWindow #11407

Closed Clover-You closed 4 days ago

Clover-You commented 6 days ago

Describe the bug

I encountered an issue while using Tauri v2. Normally, when we call APIs that require permissions, the console displays that we don't have the necessary permission (xxx).

While using WebviewWindow, I forgot to set the core:webview:allow-create-webview-window permission for the app. Unlike before, Tauri didn't inform me that I needed the core:webview:allow-create-webview-window permission to use it; instead, it threw a window not found error.

Just when I was at my wits' end, I used tauri://error and received the correct error message.

const currWindow = getCurrentWindow()

const webview = new WebviewWindow('login', { url: '/', parent: currWindow, })

webview.once('tauri://error', (err) => {
  console.log('webview creation failed: ', err)
})

webview.show()

Reproduction

https://github.com/Clover-You/tauri-window-permission-error

Expected behavior

No response

Full tauri info output

> tauri "info"

[✔] Environment
    - OS: Mac OS 15.0.1 x86_64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (default)
    - node: 22.6.0
    - pnpm: 9.10.0
    - npm: 10.8.2
    - bun: 1.1.30

[-] Packages
    - tauri 🦀: 2.0.4
    - tauri-build 🦀: 2.0.1
    - wry 🦀: 0.46.2
    - tao 🦀: 0.30.3
    - @tauri-apps/api : 2.0.2
    - @tauri-apps/cli : 2.0.3

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.1
    - @tauri-apps/plugin-shell : 2.0.0

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

Stack trace

No response

Additional context

No response

FabianLars commented 4 days ago

Just when I was at my wits' end, I used tauri://error and received the correct error message.

Due to the async nature of the IPC that's the best we can do for constructor based apis afaik.