I have the following onSnapshot
listener, and it is listening for a new document in a certain collection to post updated to a discord channel upon a new listing is added, once upon adding a new listing it shows on the website correctly and initializes the respective document correctly although upon making 2 consecutive documents I receive the following error:
[2022-10-02T16:01:22.185Z] @firebase/firestore: Firestore (9.10.0): Connection GRPC stream error. Code: 13 Message: 13 INTERNAL: Received RST_STREAM with code 0
The code looks something like this:
onSnapshot(collection(db, "items"), async (snapshot) => {
var item;
const channelRef = doc(db, "discordbot", "postchannels");
const channelSnap = getDoc(channelRef);
// channelData is a map in the format { guildId, ChannelId }
channelSnap.then(async (channelData) => {
if (channelData.exists()) {
channelData = channelData.data();
let guildId = Object.keys(channelData.itemsMap)[0]
let channelId = channelData.itemsMap[guildId]
let guild = await client.guilds.fetch(guildId)
let channel = await guild.channels.fetch(channelId)
snapshot.docChanges().forEach(async (change) => {
if (change.type === "added") {
item = change.doc.data()
channel.send({
embeds: [someEmbed]
})
}
})
}
})
})
The bot is already deployed into my server so it's rather difficult to debug in-depth, if any suggestions could be made to further debug or mitigate this error it would be much appreciated.