tauri
tauri copied to clipboard
[bug] v2 custom http client connection is silently dropped after 60 seconds timeout on MacOS
Describe the bug
tauri version: 2.0.0-beta.11
I'm using a Grpc-web client (which uses fetch) over http1 for server-streaming over Grpc endpoints.
Everything is working, except that under Tauri, and only under Tauri, a streaming connection will be silently dropped after exact 60 seconds.
For other descriptions, please see https://github.com/connectrpc/connect-es/issues/1044
I tested in other environment: serving Tauri frontend in browsers (Chrome, Safari) without Tauri instance connecting directly to the server, or connect with a local client such Postman. All these work without encountering the 60s timeout.
Under Tauri, everything works within 60 seconds. But the connection will timeout exactly after that.
If I set a shorter timeout ms on my client request, the shorter timeout will be respected, but not anything longer than 60s.
The request user-agent under Tauri:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)"
Sample request user-agent under other working environments (this example from under Safari):
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1.2 Safari/605.1.15"
Reproduction
No response
Expected behavior
A connection will respect client and server timeouts, not unknown environment timeout under Tauri.
Full tauri info output
Unhandled Promise Rejection: ConnectError: [deadline_exceeded] the operation timed out
Stack trace
No response
Additional context
No response
I'm running into this now. Not sure if this is a webkit specific thing or what...
I added a reproduction repo here
With Safari locally, fetch does not timeout by itself. It waits the full duration of the request.
It's quite annoying TBH. An AI generation may take more than a minute, and the fetch drops the connection.
I have the same issue, but one further bit of information - I can reproduce this using webkit launched from playwright (I use playwright to test my tauri webview). So this suggests to me the issue is with webkit itself (or default configuration of it), and not necessarily with tauri, unless there is configuration we can set.
I am facing this as well on MacOS with regular HTTP requests. Do You have any workaround?
@lukjaki not a nice workaround, but I resolved this by having my server send a heartbeat message every 30 seconds that the js application ignores, but this keeps the connection alive.
Thanks but I'm trying to build with OpenAI SDK and need different approach. This is critical for me as application is not usable at the moment on MacOS
@lukjaki my solution might still work for you - I'm actually proxying my calls through the tauri rust side, so while my outbound call might take longer than 60 seconds without any response, internally my proxy still sends keepalive heartbeats. I'm afraid I can't share the code but this might work for you?
Thanks @zakhenry for a tip! Looks like moving to tauri command solves issue even without heartbeat signals.