Skip to content

Commit

Permalink
handleAnything: Add try catch block while connecting to relay
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamkmr04 committed May 9, 2024
1 parent d794fc0 commit 766f50f
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions utils/handleAnything.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,23 @@ const nostrProfileLookup = async (data: string) => {
const pubkey = data;
const profilesEventsPromises = DEFAULT_NOSTR_RELAYS.map(
async (relayItem) => {
const relay = relayInit(relayItem);
relay.on('connect', () => {
console.log(`connected to ${relay.url}`);
});
relay.on('error', () => {
console.log(`failed to connect to ${relay.url}`);
});
try {
const relay = relayInit(relayItem);
relay.on('connect', () => {
console.log(`connected to ${relay.url}`);
});
relay.on('error', (): any => {
console.log(`failed to connect to ${relay.url}`);
});

await relay.connect();
return relay.list([
{
authors: [pubkey],
kinds: [0]
}
]);
await relay.connect();
return relay.list([
{
authors: [pubkey],
kinds: [0]
}
]);
} catch (e) {}
}
);

Expand Down

0 comments on commit 766f50f

Please sign in to comment.