go-ethereum/rpc
Delweng 0413af40f6
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
rpc: fix a flaky test of the websocket (#33002)
Found in
https://github.com/ethereum/go-ethereum/actions/runs/17803828253/job/50611300621?pr=32585

```
--- FAIL: TestClientCancelWebsocket (0.33s)
panic: read tcp 127.0.0.1:36048->127.0.0.1:38643: read: connection reset by peer [recovered, repanicked]

goroutine 15 [running]:
testing.tRunner.func1.2({0x98dd20, 0xc0005b0100})
	/opt/actions-runner/_work/_tool/go/1.25.1/x64/src/testing/testing.go:1872 +0x237
testing.tRunner.func1()
	/opt/actions-runner/_work/_tool/go/1.25.1/x64/src/testing/testing.go:1875 +0x35b
panic({0x98dd20?, 0xc0005b0100?})
	/opt/actions-runner/_work/_tool/go/1.25.1/x64/src/runtime/panic.go:783 +0x132
github.com/ethereum/go-ethereum/rpc.httpTestClient(0xc0001dc1c0?, {0x9d5e40, 0x2}, 0xc0002bc1c0)
	/opt/actions-runner/_work/go-ethereum/go-ethereum/rpc/client_test.go:932 +0x2b1
github.com/ethereum/go-ethereum/rpc.testClientCancel({0x9d5e40, 0x2}, 0xc0001dc1c0)
	/opt/actions-runner/_work/go-ethereum/go-ethereum/rpc/client_test.go:356 +0x15f
github.com/ethereum/go-ethereum/rpc.TestClientCancelWebsocket(0xc0001dc1c0?)
	/opt/actions-runner/_work/go-ethereum/go-ethereum/rpc/client_test.go:319 +0x25
testing.tRunner(0xc0001dc1c0, 0xa07370)
	/opt/actions-runner/_work/_tool/go/1.25.1/x64/src/testing/testing.go:1934 +0xea
created by testing.(*T).Run in goroutine 1
	/opt/actions-runner/_work/_tool/go/1.25.1/x64/src/testing/testing.go:1997 +0x465
FAIL	github.com/ethereum/go-ethereum/rpc	0.371s
```

In `testClientCancel` we wrap the server listener in `flakeyListener`,
which schedules an unconditional close of every accepted connection
after a random delay, if the random delay is zero then the timer fires
immediately, and then the http client paniced of connection reset by
peer.

Here we add a minimum 10ms to ensure the timeout won't fire immediately.

Signed-off-by: jsvisa <delweng@gmail.com>
2025-10-23 20:58:33 +08:00
..
testdata rpc: add limit for batch request items and response size (#26681) 2023-06-13 13:38:58 +02:00
client.go internal: remove unused shh and swarm modules from console (#32073) 2025-07-01 19:51:16 +08:00
client_example_test.go rpc: make ExampleClientSubscription work with the geth API (#19483) 2020-04-27 17:25:24 +02:00
client_opt.go eth, rpc: add configurable option for wsMessageSizeLimit (#27801) 2023-10-03 03:23:19 -04:00
client_opt_test.go all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00
client_test.go rpc: fix a flaky test of the websocket (#33002) 2025-10-23 20:58:33 +08:00
context_headers.go rpc: support injecting HTTP headers through context (#26023) 2022-11-16 15:22:12 +01:00
doc.go all: update dead wiki links (#32215) 2025-07-15 06:24:17 -06:00
endpoints.go trie, rpc, cmd/geth: fix tests on 32-bit and windows + minor rpc fixes (#21871) 2020-11-19 22:50:47 +01:00
errors.go rpc: add method to test for subscription support (#25942) 2023-06-14 14:04:41 +02:00
handler.go rpc: add method name length limit (#31711) 2025-05-05 14:43:47 +02:00
http.go internal/build, rpc: add missing HTTP response body Close() calls (#29223) 2024-03-12 12:12:37 +01:00
http_test.go rpc: run tests in parallel (#30384) 2024-11-19 13:43:33 +01:00
inproc.go rpc: add limit for batch request items and response size (#26681) 2023-06-13 13:38:58 +02:00
ipc.go rpc: add limit for batch request items and response size (#26681) 2023-06-13 13:38:58 +02:00
ipc_js.go all: add go:build lines (#23468) 2021-08-25 18:46:29 +02:00
ipc_unix.go rpc: fix ipc max path size (#29385) 2024-04-02 11:25:19 +02:00
ipc_wasip1.go all: add build tags for wasip1 (#31090) 2025-01-30 16:58:53 +01:00
ipc_windows.go rpc: use go-winio for named pipes (#27972) 2023-08-23 04:39:01 +02:00
json.go rpc: add method name length limit (#31711) 2025-05-05 14:43:47 +02:00
metrics.go rpc: fix ns/µs mismatch in metrics (#28649) 2023-12-08 09:40:50 +01:00
server.go rpc: add SetWebsocketReadLimit in Server (#32279) 2025-08-19 14:32:59 +08:00
server_test.go rpc: fix flaky test TestServerWebsocketReadLimit (#32889) 2025-10-15 15:39:00 +08:00
service.go rpc: use reflect.TypeFor (#32316) 2025-08-07 14:15:54 +02:00
stdio.go rpc: add limit for batch request items and response size (#26681) 2023-06-13 13:38:58 +02:00
subscription.go rpc: add timeout to rpc client Unsubscribe (#30318) 2024-08-20 15:54:28 +02:00
subscription_test.go internal: remove unused shh and swarm modules from console (#32073) 2025-07-01 19:51:16 +08:00
testservice_test.go rpc: remove deprecated method "Notifier.Closed" (#29162) 2024-03-05 14:44:23 +01:00
types.go eth, eth/filters: implement API error code for pruned blocks (#31361) 2025-04-01 13:42:01 +02:00
types_test.go rpc: run tests in parallel (#30384) 2024-11-19 13:43:33 +01:00
websocket.go rpc: add SetWebsocketReadLimit in Server (#32279) 2025-08-19 14:32:59 +08:00
websocket_test.go rpc: refactor read limit test (#32494) 2025-08-26 23:43:51 +02:00