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

[bug] can not send empty Unit8Array data by ipc in the v2 #9787

Closed
tiger-with-wings opened this issue May 15, 2024 · 0 comments · Fixed by tauri-apps/wry#1267
Closed

[bug] can not send empty Unit8Array data by ipc in the v2 #9787

tiger-with-wings opened this issue May 15, 2024 · 0 comments · Fixed by tauri-apps/wry#1267
Labels
priority: 1 high status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@tiger-with-wings
Copy link

Describe the bug

If the Unit8Array data is not empty, it can be sent successfully:
image
image

If the data is empty, the sending will fail. And will cause the program to crash.
image
image

Primary code
Code of rust

#[tauri::command]
pub fn test_new_ipc(request: Request<'_>) -> Result<Response, &str> {
    if let InvokeBody::Raw(data) = request.body() {
        println!("{:?}", data.clone());
        Ok(Response::new(data.clone()))
    } else {
        Err("Not binary data.")
    }
}

Code of ts

const textEncoder = new TextEncoder();
const textDecoder = new TextDecoder();
const data = textEncoder.encode(requestMsg);
console.log(data);
// Just for screenshot observation of the data sent. 
setTimeout(() => {
   invoke<Uint8Array>("test_new_ipc", data)
    .then(res => setResponseMsg(textDecoder.decode(res)))
    .catch(err => console.error(err));
}, 5000);

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.2.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 18.20.2
    - pnpm: 9.1.0
    - npm: 10.5.0

[-] Packages
    - tauri [RUST]: 2.0.0-beta.19
    - tauri-build [RUST]: 2.0.0-beta.15
    - wry [RUST]: 0.39.5
    - tao [RUST]: 0.28.0
    - @tauri-apps/api [NPM]: 2.0.0-beta.11
    - @tauri-apps/cli [NPM]: 2.0.0-beta.17

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

Stack trace

2024-05-15 16:32:35.972 tauri-app-pc[57048:2111556] TSM AdjustCapsLockLEDForKeyTransitionHandling - _ISSetPhysicalKeyboardCapsLockLED Inhibit
[49, 50, 51]
2024-05-15 16:33:28.446 tauri-app-pc[57048:2111556] _TIPropertyValueIsValid called with 12 on nil context!
2024-05-15 16:33:28.446 tauri-app-pc[57048:2111556] imkxpc_setApplicationProperty:value:reply: called with incorrect property value 12, bailing.
thread 'main' panicked at library/core/src/panicking.rs:156:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
 ELIFECYCLE  Command failed with exit code 1.

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: 1 high 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.

3 participants