From 761143a317ead1b6c4e5d82ffc954f5a4f32702e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 31 May 2024 13:58:06 -0500 Subject: [PATCH] relay: give a nice "fuck you" to clients sending invalid filters --- src/controllers/nostr/relay.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/nostr/relay.ts b/src/controllers/nostr/relay.ts index 6fc08d0..5d08e02 100644 --- a/src/controllers/nostr/relay.ts +++ b/src/controllers/nostr/relay.ts @@ -63,8 +63,14 @@ function connectStream(socket: WebSocket) { const store = await Storages.db(); const pubsub = await Storages.pubsub(); - for (const event of await store.query(filters, { limit: FILTER_LIMIT })) { - send(['EVENT', subId, event]); + try { + for (const event of await store.query(filters, { limit: FILTER_LIMIT })) { + send(['EVENT', subId, event]); + } + } catch (e) { + send(['CLOSED', subId, e.message]); + controllers.delete(subId); + return; } send(['EOSE', subId]);