tauri icon indicating copy to clipboard operation
tauri copied to clipboard

Error after 30 seconds of fetch execution.

Open roiiiu opened this issue 3 years ago • 4 comments

Describe the bug

I have a long executing request on my Go backend and once the fetch request takes more than 30 seconds, I get this error. With axios everything works fine. image

await fetch('http://localhost:8080/g4', {
    method: 'POST',
  })
r := gin.Default()
r.POST("/g4", func(c *gin.Context) {
    time.Sleep(40 * time.Second)
}

Reproduction

Expected behavior

No response

Platform and versions

Environment › OS: Mac OS 12.6.0 X64 › Node.js: 18.10.0 › npm: 8.19.2 › pnpm: 7.13.0 › yarn: 1.22.19 › rustup: Not installed! › rustc: 1.64.0 › cargo: 1.64.0 › Rust toolchain:

Packages › @tauri-apps/cli [NPM]: 1.1.1 › @tauri-apps/api [NPM]: 1.1.0 › tauri [RUST]: 1.1.1, › tauri-build [RUST]: 1.1.1, › tao [RUST]: 0.14.0, › wry [RUST]: 0.21.1,

App › build-type: bundle › CSP: unset › distDir: ../dist › devPath: http://localhost:1420/ › framework: Vue.js

App directory structure ├─ dist ├─ node_modules ├─ public ├─ src-tauri ├─ .git ├─ .vscode └─ src

Stack trace

No response

Additional context

No response

roiiiu avatar Oct 04 '22 11:10 roiiiu

As far as i know attohttpc (the http client our fetch implementation uses by default) has a default timeout of 30 seconds. You could try changing the request timeout to a higher number or to 0 which should disable it:

await fetch('http://localhost:8080/g4', {
    method: 'POST',
    timeout: 60
  })

FabianLars avatar Oct 04 '22 11:10 FabianLars

I have tried but this doesn't work and the error report for timeout is not the same. image

roiiiu avatar Oct 04 '22 11:10 roiiiu

Can you try the reqwest client then to check if it's not related to attohttpc#118. You can switch the client by adding the "reqwest-client" feature flag to the tauri dependency in Cargp.toml

FabianLars avatar Oct 04 '22 12:10 FabianLars

Can you try the reqwest client then to check if it's not related to attohttpc#118. You can switch the client by adding the "reqwest-client" feature flag to the tauri dependency in Cargp.toml

Yes,it worked now,Thanks!

roiiiu avatar Oct 04 '22 12:10 roiiiu

attohttpc will be removed in tauri v2: https://github.com/tauri-apps/tauri/pull/6468

FabianLars avatar Mar 17 '23 12:03 FabianLars