```
async userLeadsChannel(
fid: string,
farcasterChannelID: string,
): Promise<boolean> {
const userChannelsPromise = (async () => {
const ledChannels = await this.fetchLedFarcasterChannels(fid);
const result = ledChannels.some(
channel => channel.id === farcasterChannelID,
);
if (farcasterChannelID === 'bromero') {
console.log('user channels result:', result);
console.log('led channels:', ledChannels);
}
return { result, source: 'userChannels' };
})();
const channelSearchPromise = (async () => {
try {
const channel =
await this.fetchFarcasterChannelByName(farcasterChannelID);
const result = channel?.lead.fid === parseInt(fid);
if (farcasterChannelID === 'bromero') {
console.log('channel search result:', result);
console.log('channel details:', channel);
}
return { result, source: 'channelSearch' };
} catch (e) {
// Wait 5 seconds to give the other promise a chance to settle
console.log('sleeping');
await sleep(5000);
throw e;
}
})();
const { result, source } = await Promise.race([
userChannelsPromise,
channelSearchPromise,
]);
console.log(`Promise from ${source} settled first.`);
return result; // Only return the boolean result
}
```
modified my function to see which promise settled first, and as expected, in the first batch of 5, the `channelSearchPromise` settled first, but afterwards the `userChannelsPromise` always settled first.
modified `fetchFarcasterChannelByName` to throw and confirmed that the promise still resolved with the result form `userChannelsPromise` (simulates, for example, a 429 Too Many Requests response)
also confirmed that function returns true for channel `bromero`, which I confirmed is led by j4ck.eth (whose fid i used for my test user)