tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] v2 custom http client connection is silently dropped after 60 seconds timeout on MacOS

Open boan-anbo opened this issue 1 year ago • 3 comments

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

boan-anbo avatar Mar 18 '24 03:03 boan-anbo

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. Screenshot 2024-07-30 at 3 49 17 PM

WalrusSoup avatar Jul 30 '24 19:07 WalrusSoup

It's quite annoying TBH. An AI generation may take more than a minute, and the fetch drops the connection.

vladfaust avatar Aug 18 '24 15:08 vladfaust

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.

zakhenry avatar Nov 25 '24 22:11 zakhenry

I am facing this as well on MacOS with regular HTTP requests. Do You have any workaround?

lukjaki avatar Mar 03 '25 14:03 lukjaki

@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.

zakhenry avatar Mar 03 '25 14:03 zakhenry

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 avatar Mar 03 '25 15:03 lukjaki

@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?

zakhenry avatar Mar 03 '25 15:03 zakhenry

Thanks @zakhenry for a tip! Looks like moving to tauri command solves issue even without heartbeat signals.

lukjaki avatar Mar 03 '25 15:03 lukjaki