Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion json_rpc/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ proc call*(client: RpcClient, name: string,
{.async: (raw: true).} =
client.call(name, params.paramsTx)

method close*(client: RpcClient): Future[void] {.base, async.} =
method close*(client: RpcClient): Future[void] {.base, async: (raises: []).} =
raiseAssert("`RpcClient.close` not implemented")

method callBatch*(client: RpcClient,
Expand Down
2 changes: 1 addition & 1 deletion json_rpc/clients/httpclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ proc connect*(client: RpcHttpClient, address: string, port: Port, secure: bool)
client.httpAddress = getAddress(client.httpSession, uri).valueOr:
raise newException(RpcAddressUnresolvableError, error)

method close*(client: RpcHttpClient) {.async.} =
method close*(client: RpcHttpClient) {.async: (raises: []).} =
if not client.httpSession.isNil:
await client.httpSession.closeWait()

Expand Down
2 changes: 1 addition & 1 deletion json_rpc/clients/socketclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ proc connect*(client: RpcSocketClient, address: TransportAddress) {.async.} =
client.address = address
client.loop = processData(client)

method close*(client: RpcSocketClient) {.async.} =
method close*(client: RpcSocketClient) {.async: (raises: []).} =
await client.loop.cancelAndWait()
if not client.transport.isNil:
client.transport.close()
Expand Down
8 changes: 6 additions & 2 deletions json_rpc/clients/websocketclientimpl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,12 @@ proc connect*(
client.uri = uri
client.loop = processData(client)

method close*(client: RpcWebSocketClient) {.async.} =
method close*(client: RpcWebSocketClient) {.async: (raises: []).} =
await client.loop.cancelAndWait()
if not client.transport.isNil:
await client.transport.close()
try:
# TODO https://github.com/status-im/nim-websock/pull/178
await noCancel client.transport.close()
except CatchableError as exc:
warn "Unexpected exception while closing transport", err = exc.msg
client.transport = nil
4 changes: 2 additions & 2 deletions json_rpc/rpcproxy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ proc registerProxyMethod*(proxy: var RpcProxy, methodName: string) =
# Adding proc type to table gives invalid exception tracking, see Nim bug: https://github.com/nim-lang/Nim/issues/18376
raiseAssert err.msg

proc stop*(proxy: RpcProxy) {.async.} =
proc stop*(proxy: RpcProxy) {.async: (raises: []).} =
await proxy.getClient().close()
await proxy.rpcHttpServer.stop()

proc closeWait*(proxy: RpcProxy) {.async.} =
proc closeWait*(proxy: RpcProxy) {.async: (raises: []).} =
await proxy.rpcHttpServer.closeWait()

func localAddress*(proxy: RpcProxy): seq[TransportAddress] =
Expand Down
4 changes: 2 additions & 2 deletions json_rpc/servers/httpserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ proc start*(server: RpcHttpServer) =
info "Starting JSON-RPC HTTP server", url = item.baseUri
item.start()

proc stop*(server: RpcHttpServer) {.async.} =
proc stop*(server: RpcHttpServer) {.async: (raises: []).} =
## Stop the RPC server.
for item in server.httpServers:
await item.stop()
info "Stopped JSON-RPC HTTP server", url = item.baseUri

proc closeWait*(server: RpcHttpServer) {.async.} =
proc closeWait*(server: RpcHttpServer) {.async: (raises: []).} =
## Cleanup resources of RPC server.
for item in server.httpServers:
await item.closeWait()
Expand Down
2 changes: 1 addition & 1 deletion json_rpc/servers/socketserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ proc close*(server: RpcSocketServer) =
for item in server.servers:
item.close()

proc closeWait*(server: RpcSocketServer) {.async.} =
proc closeWait*(server: RpcSocketServer) {.async: (raises: []).} =
## Cleanup resources of RPC server.
for item in server.servers:
await item.closeWait()
Expand Down
4 changes: 1 addition & 3 deletions json_rpc/servers/websocketserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import
chronicles, chronos, websock/[websock, types],
websock/extensions/compression/deflate,
stew/byteutils,
json_serialization/std/net as jsnet,

../[errors, server]

export errors, server, jsnet
Expand Down Expand Up @@ -246,7 +244,7 @@ proc close*(server: RpcWebSocketServer) =
## Cleanup resources of RPC server.
server.server.close()

proc closeWait*(server: RpcWebSocketServer) {.async.} =
proc closeWait*(server: RpcWebSocketServer) {.async: (raises: []).} =
## Cleanup resources of RPC server.
await server.server.closeWait()

Expand Down
Loading