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
3 changes: 3 additions & 0 deletions waku/waku_filter_v2/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ proc sendSubscribeRequest(

let connection = connOpt.get()

defer:
await connection.closeWithEOF()

try:
await connection.writeLP(filterSubscribeRequest.encode().buffer)
except CatchableError:
Expand Down
3 changes: 3 additions & 0 deletions waku/waku_filter_v2/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ proc initProtocolHandler(wf: WakuFilter) =

var response: FilterSubscribeResponse

defer:
await conn.closeWithEOF()

wf.peerRequestRateLimiter.checkUsageLimit(WakuFilterSubscribeCodec, conn):
var buf: seq[byte]
try:
Expand Down
3 changes: 3 additions & 0 deletions waku/waku_lightpush/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ proc sendPushRequest(
dialFailure & ": " & $peer & " is not accessible",
)

defer:
await connection.closeWithEOF()

await connection.writeLP(req.encode().buffer)

var buffer: seq[byte]
Expand Down
3 changes: 3 additions & 0 deletions waku/waku_lightpush/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ proc handleRequest*(
proc initProtocolHandler(wl: WakuLightPush) =
proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} =
var rpc: LightPushResponse
defer:
await conn.closeWithEOF()

wl.requestRateLimiter.checkUsageLimit(WakuLightPushCodec, conn):
var buffer: seq[byte]
try:
Expand Down
3 changes: 3 additions & 0 deletions waku/waku_lightpush_legacy/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ proc sendPushRequest(
return err(dialFailure)
let connection = connOpt.get()

defer:
await connection.closeWithEOF()

let rpc = PushRPC(requestId: generateRequestId(wl.rng), request: some(req))
await connection.writeLP(rpc.encode().buffer)

Expand Down
3 changes: 3 additions & 0 deletions waku/waku_lightpush_legacy/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ proc handleRequest*(
proc initProtocolHandler(wl: WakuLegacyLightPush) =
proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} =
var rpc: PushRPC
defer:
await conn.closeWithEOF()

wl.requestRateLimiter.checkUsageLimit(WakuLegacyLightPushCodec, conn):
var buffer: seq[byte]
try:
Expand Down
3 changes: 3 additions & 0 deletions waku/waku_store/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ proc sendStoreRequest(
): Future[StoreQueryResult] {.async, gcsafe.} =
var req = request

defer:
await connection.closeWithEof()

if req.requestId == "":
req.requestId = generateRequestId(self.rng)

Expand Down
4 changes: 4 additions & 0 deletions waku/waku_store/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ proc initProtocolHandler(self: WakuStore) =
var successfulQuery = false ## only consider the correct queries in metrics
var resBuf: StoreResp
var queryDuration: float

defer:
await conn.closeWithEof()

self.requestRateLimiter.checkUsageLimit(WakuStoreCodec, conn):
let readRes = catch:
await conn.readLp(DefaultMaxRpcSize.int)
Expand Down
3 changes: 3 additions & 0 deletions waku/waku_store_legacy/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ proc sendHistoryQueryRPC(

let connection = connOpt.get()

defer:
await connection.closeWithEof()

let requestId =
if req.requestId != "":
req.requestId
Expand Down
4 changes: 4 additions & 0 deletions waku/waku_store_legacy/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ proc initProtocolHandler(ws: WakuStore) =
var successfulQuery = false ## only consider the correct queries in metrics
var resBuf: StoreResp
var queryDuration: float

defer:
await conn.closeWithEof()

ws.requestRateLimiter.checkUsageLimit(WakuLegacyStoreCodec, conn):
let readRes = catch:
await conn.readLp(DefaultMaxRpcSize.int)
Expand Down
Loading