go-ethereum/rpc
Daniel Liu 58e9b8c8f6
node, rpc: improve HTTP write timeout handling #25457 (#982)
Here we add special handling for sending an error response when the write timeout of the
HTTP server is just about to expire. This is surprisingly difficult to get right, since is
must be ensured that all output is fully flushed in time, which needs support from
multiple levels of the RPC handler stack:

The timeout response can't use chunked transfer-encoding because there is no way to write
the final terminating chunk. net/http writes it when the topmost handler returns, but the
timeout will already be over by the time that happens. We decided to disable chunked
encoding by setting content-length explicitly.

Gzip compression must also be disabled for timeout responses because we don't know the
true content-length before compressing all output, i.e. compression would reintroduce
chunked transfer-encoding.

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-04-25 08:01:44 +08:00
..
testdata rpc: improve error codes for internal server errors #25678 (#974) 2025-04-24 19:03:29 +08:00
client.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
client_example_test.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
client_test.go rpc: handle wrong HTTP batch response length #26064 (#975) 2025-04-24 19:06:19 +08:00
constants_unix.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
constants_unix_nocgo.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
context_headers.go rpc: support injecting HTTP headers through context #26023 (#977) 2025-04-24 19:08:16 +08:00
doc.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
endpoints.go console: handle eth.coinbase throws #19374 (#953) 2025-04-24 18:11:48 +08:00
errors.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
handler.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
http.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
http_test.go rpc: support injecting HTTP headers through context #26023 (#977) 2025-04-24 19:08:16 +08:00
inproc.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
ipc.go rpc: clean up IPC handler (#16524) 2024-11-04 12:31:15 +08:00
ipc_js.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
ipc_unix.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
ipc_wasip1.go all: add build tags for wasip1 (#31090) 2025-03-19 18:02:46 +08:00
ipc_windows.go console: handle eth.coinbase throws #19374 (#953) 2025-04-24 18:11:48 +08:00
json.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
metrics.go rpc: fix ns/µs mismatch in metrics (#28649) 2024-12-13 14:00:13 +08:00
server.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
server_test.go rpc: improve error codes for internal server errors #25678 (#974) 2025-04-24 19:03:29 +08:00
service.go rpc: improve error codes for internal server errors #25678 (#974) 2025-04-24 19:03:29 +08:00
stdio.go upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
subscription.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
subscription_test.go rpc: check that version is 2.0 in request objects #25570 (#973) 2025-04-24 19:02:33 +08:00
testservice_test.go rpc: improve error codes for internal server errors #25678 (#974) 2025-04-24 19:03:29 +08:00
types.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
types_test.go rpc: implement JSON marshaling of BlockNumber #23324 (#958) 2025-04-24 18:20:03 +08:00
websocket.go node, rpc: improve HTTP write timeout handling #25457 (#982) 2025-04-25 08:01:44 +08:00
websocket_test.go rpc, internal/guide: speed up tests a bit #26193 (#981) 2025-04-24 22:08:58 +08:00