relay: give a nice "fuck you" to clients sending invalid filters

This commit is contained in:
Alex Gleason 2024-05-31 13:58:06 -05:00
parent 5ca1e2fd26
commit 761143a317
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 8 additions and 2 deletions

View File

@ -63,8 +63,14 @@ function connectStream(socket: WebSocket) {
const store = await Storages.db(); const store = await Storages.db();
const pubsub = await Storages.pubsub(); const pubsub = await Storages.pubsub();
for (const event of await store.query(filters, { limit: FILTER_LIMIT })) { try {
send(['EVENT', subId, event]); 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]); send(['EOSE', subId]);