plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

plugin-http closes the connection whenever keep-alive is set

Open hexadecimal233 opened this issue 2 months ago • 6 comments

I was accesing an API endpoint and opening the connection takes around 5 secs which is very annoying, and keep-alive can easily fix this.

In WebView2, keep-alive works fine, and in tauri, connection is closed after every fetch, so it takes HUGE amounts of time to send multiple requests to the server.

code (with unsafe headers enabled and url whitelisted)

import { fetch } from "@tauri-apps/plugin-http"

async function debug() {
  for (let index = 0; index < 5; index++) {
    const response = await fetch("https://httpbin.org/headers", {
      method: "GET",
      headers: {
        Connection: "keep-alive",
      },
    })
    console.log("request "+ index, await response.json())
  }
}

await debug()

you can use packet tracers to see the connection is closed after a request has finished

hexadecimal233 avatar Oct 01 '25 11:10 hexadecimal233