Skip to content

[bug] invoke does not handle Headers correctly #13223

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

Closed
WSH032 opened this issue Apr 13, 2025 · 1 comment · Fixed by #13227
Closed

[bug] invoke does not handle Headers correctly #13223

WSH032 opened this issue Apr 13, 2025 · 1 comment · Fixed by #13227
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@WSH032
Copy link
Contributor

WSH032 commented Apr 13, 2025

Describe the bug

...((options && options.headers) || {})

...options.headers works for { foo: "bar" } but does not work for a Headers object.

Reproduction

import { invoke } from "@tauri-apps/api/core";

// work ⭐
await invoke("foo", undefined, {
  headers: {
    foo: "bar"
  }
});

// not work ❌
const headers = new Headers({ foo: "bar" });
await invoke("foo", undefined, {
  headers
});

Can't receive foo: "bar" header in backend.

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.19045 x86_64 (X64)
    ✔ WebView2: 135.0.3179.73
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.83.0 (90b35a623 2024-11-26)
    ✔ cargo: 1.83.0 (5ffbef321 2024-10-29)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.11.1
    - pnpm: 9.10.0
    - npm: 10.2.4

[-] Packages
    - tauri 🦀: 2.4.0
    - tauri-build 🦀: 2.1.0
    - wry 🦀: 0.50.5
    - tao 🦀: 0.32.8
    - tauri-cli 🦀: 2.2.7
    - @tauri-apps/api : 2.1.1 (outdated, latest: 2.4.1)
    - @tauri-apps/cli : 2.2.7 (outdated, latest: 2.4.1)

[-] Plugins
    - tauri-plugin-opener 🦀: 2.2.6
    - @tauri-apps/plugin-opener : 2.2.2 (outdated, latest: 2.2.6)
    - tauri-plugin-dialog 🦀: 2.2.0
    - @tauri-apps/plugin-dialog : not installed!
    - tauri-plugin-clipboard-manager 🦀: 2.2.2
    - @tauri-apps/plugin-clipboard-manager : not installed!
    - tauri-plugin-fs 🦀: 2.2.0
    - @tauri-apps/plugin-fs : not installed!
    - tauri-plugin-notification 🦀: 2.2.2
    - @tauri-apps/plugin-notification : not installed!

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

Stack trace


Additional context

I have not checked the case for isolation mode because I don't quite understand how to use this mode (its documentation is not very clear 😵).

@WSH032 WSH032 added status: needs triage This issue needs to triage, applied to new issues type: bug labels Apr 13, 2025
@Legend-Master
Copy link
Contributor

Hey, do you mind give #13227 a try and see if it indeed fixes the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants