From 1c20de4587b9bd15ad3564205ca7f049312e2abe Mon Sep 17 00:00:00 2001 From: Yonle Date: Tue, 16 Apr 2024 02:25:10 +0700 Subject: [PATCH] nostr-tools being randomly throw error in their own code. Put safety. Signed-off-by: Yonle --- bouncer.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bouncer.js b/bouncer.js index 1464fc2..320d378 100644 --- a/bouncer.js +++ b/bouncer.js @@ -272,6 +272,15 @@ function getIdleSess(ws) { newsess(); } +function _matchFilters(filters, event) { + // nostr-tools being randomly throw error in their own code. Put safety. + try { + return matchFilters(filters, event); + } catch { + return false; + } +} + // WS - Sessions function newConn(addr, id, reconn_t = 0) { if (!csess.has(id)) return; @@ -328,7 +337,7 @@ function newConn(addr, id, reconn_t = 0) { if (client.rejectKinds && client.rejectKinds.includes(data[2]?.id)) return; const filters = client.subs.get(data[1]); - if (!matchFilters(filters, data[2])) return; + if (!_matchFilters(filters, data[2])) return; const NotInSearchQuery = "search" in filter && !data[2]?.content?.toLowerCase().includes(filter.search.toLowerCase()); if (NotInSearchQuery) return;