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] http.fetch with timeout integer config cause error #4004

Closed
rming opened this issue Apr 29, 2022 · 4 comments
Closed

[bug] http.fetch with timeout integer config cause error #4004

rming opened this issue Apr 29, 2022 · 4 comments
Assignees
Labels
scope: api.js The @tauri-apps/api npm package type: bug

Comments

@rming
Copy link
Contributor

rming commented Apr 29, 2022

Describe the bug

http.fetch with config {timeout: 12} cause Error

invalid type: integer `12`, expected struct Duration

test code : https://github.com/Rming/tauri-example

Reproduction

  1. clone test code and run cargo tauri dev
  2. error will output in the console

Expected behavior

https://tauri.studio/docs/api/js/interfaces/http.HttpOptions#timeout
may be a bug or doc needs to be updated

Platform and versions

Environment
  › OS: Mac OS 12.3.1 X64
  › Node.js: 17.6.0
  › npm: 8.5.1
  › pnpm: Not installed!
  › yarn: 1.22.17
  › rustup: 1.24.3
  › rustc: 1.59.0
  › cargo: 1.59.0
  › Rust toolchain: stable-aarch64-apple-darwin

Packages
WARNING: no lock files found, defaulting to npm
  › @tauri-apps/cli [NPM]: 1.0.0-rc.9
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unexpected end of input while parsing major version number")', /Users/afa/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/tauri-cli-1.0.0-rc.9/src/info.rs:535:67
stack backtrace:
   0:        0x104a78314 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h58c637f9e30d1b8a
   1:        0x104832504 - core::fmt::write::hc16ca97d9f5e0acd
   2:        0x104a731dc - std::io::Write::write_fmt::hd53dc7153ccce04d
   3:        0x104a7d734 - std::panicking::default_hook::{{closure}}::ha41f2cf175ca93cf
   4:        0x104a7d374 - std::panicking::default_hook::h838498b157804a1a
   5:        0x104a7e398 - std::panicking::rust_panic_with_hook::h7722806c30430655
   6:        0x104a7e0bc - std::panicking::begin_panic_handler::{{closure}}::h265229fa7cad6de7
   7:        0x104a7e028 - std::sys_common::backtrace::__rust_end_short_backtrace::hfa83d61d0ed14557
   8:        0x104a7dff4 - _rust_begin_unwind
   9:        0x104ca6048 - core::panicking::panic_fmt::hd3f68d55261c2af0
  10:        0x104ca6220 - core::result::unwrap_failed::hc1b85f369312af72
  11:        0x104bab590 - tauri_cli::info::VersionBlock::display::h600532245a508e80
  12:        0x104ba5578 - tauri_cli::info::command::hba1cf1976b5f6b66
  13:        0x1047e8730 - tauri_cli::run::h77dad4afa2b4e229
  14:        0x1047f2bfc - cargo_tauri::main::hfb371fa95b68fdc0
  15:        0x1047f2030 - std::sys_common::backtrace::__rust_begin_short_backtrace::h675900a9f970608c
  16:        0x1047f239c - _main
  › @tauri-apps/api

Stack trace

No response

Additional context

No response

@rming rming changed the title [bug] [bug] http.fetch with timeout integer config cause error Apr 29, 2022
@amrbashir amrbashir added the scope: api.js The @tauri-apps/api npm package label Apr 29, 2022
@lucasfernog lucasfernog self-assigned this Apr 29, 2022
@FabianLars
Copy link
Member

hmm idk, imo it's such a weird design choice that serde's default Deserialize impl for Duration expects this format:

{
  "secs": number,
  "nanos": number,
}

It's understandable from a rust POV i guess, but the chances seeing this format in any json blob is fairly low 😅

@lucasfernog
Copy link
Member

Yeah for now we can just map an integer to that object.

@lucasfernog
Copy link
Member

serde-rs/serde#339 (comment) :|

@lucasfernog
Copy link
Member

Until the next release is published, you can change {timeout: 12} to {timeout: { secs: 12, nanos: 0 }}. Sorry about that :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: api.js The @tauri-apps/api npm package type: bug
Projects
None yet
Development

No branches or pull requests

4 participants