on master help sign in
Hard-code long poll timeout to 20 seconds
commit9d1c5257b1047e6b872011c71876249835d2698b authoriko <mail@iko.soy> dateSun 19 Apr 2026, 00:39 (6 months ago) parent1fa6993
3 files changed+7−9
PROTOCOL.md+1−2 client/ApiClient.fs+1−1 server.knot+5−6
PROTOCOL.md+1−2
@@ -364,7 +364,6 @@ The client makes a blocking GET request. The server holds the connection open un
364364
365365| Parameter | Type | Description |
366366|--------------|--------|--------------------------------------------------|
367−| `timeout` | number | Max seconds to wait (default: 30, max: 60) |
368367| `after` | string | Cursor from the previous poll response (optional) |
369368
370369**Response:**
@@ -382,7 +381,7 @@ The client makes a blocking GET request. The server holds the connection open un
382381```
383382
384383- If events are available immediately, the server responds right away.
385−- If no events are available, the server holds the connection until one arrives or `timeout` expires.
384+- If no events are available, the server holds the connection for up to 20 seconds.
386385- On timeout with no events, the server returns `{ "events": [], "cursor": "..." }`.
387386- The client should immediately issue the next poll after receiving a response.
388387
client/ApiClient.fs+1−1
@@ -104,7 +104,7 @@ module ApiClient =
104104 }
105105
106106 let poll (serverUrl: string) (token: string) (cursor: int64) =
107− let body = JsonSerializer.Serialize({| cursor = cursor; timeout = 30000 |})
107+ let body = JsonSerializer.Serialize({| cursor = cursor |})
108108 postJson<PollResponse> pollClient $"{serverUrl}/poll" body (Some token)
109109
110110 let ackMessages (serverUrl: string) (token: string) (messageIds: string list) =
server.knot+5−6
@@ -44,8 +44,8 @@ offlineGossipMinTtl = 60 -- minimum TTL for offline gossip events
4444maxForwardRetriesPerServer = 100
4545maxGossipHops = 5
4646gossipOriginHops = 2
47−maxPollTimeout : Int<Ms>
48−maxPollTimeout = 60000 -- 1 minute
47+pollTimeout : Int<Ms>
48+pollTimeout = 20000 -- 20 seconds
4949backgroundPruneInterval : Int<Ms>
5050backgroundPruneInterval = 30000 -- 30 seconds
5151federationEnabled = federationSecret != ""
@@ -153,7 +153,7 @@ route AuthApi where
153153 = VerifyAuth
154154
155155route ClientApi where
156− POST {cursor: Timestamp, timeout: Int<Ms>} /poll headers {authorization: Text}
156+ POST {cursor: Timestamp} /poll headers {authorization: Text}
157157 -> {events: [PollEvent], cursor: Timestamp, authorized: Bool}
158158 = Poll
159159 /messages
@@ -916,10 +916,9 @@ serve = \req -> case req of
916916 broadcastOfflineGossip t result.pr.peerServers expiredLocal)
917917 yield (respond {token: token, expiresAt: expiry})
918918
919− Poll {cursor, timeout, authorization, respond} -> do
919+ Poll {cursor, authorization, respond} -> do
920920 t <- now
921− let clampedTimeout = clamp 0 maxPollTimeout timeout
922− let deadline = t + clampedTimeout
921+ let deadline = t + pollTimeout
923922 result <- case extractToken authorization of
924923 Nothing {} -> yield (PollUnauthorized {})
925924 Just {value: token} -> pollLoop token cursor deadline