2

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.

Zero
  • 2,164
  • 1
  • 9
  • 28
  • Have a look at this github [issue](https://github.com/googleapis/nodejs-firestore/issues/1023) & stackoverflow [link](https://stackoverflow.com/a/58554698/18265638) – Sathi Aiswarya Oct 03 '22 at 09:45
  • The GitHub issue and the stackoverflow link refers to packages "@google-cloud/firestore" and "firebase-functions", while my sole dependency giving the error is "@firebase/firestore" , i wouldn't be able to fix the error in a similar fashion since my package is already up to date – Zero Oct 04 '22 at 04:04
  • Should I switch dependencies? – Zero Oct 04 '22 at 04:05
  • please check this [github](https://github.com/grpc/grpc-node/issues/1532) if the issue still persists, create a reproduce case and post your issue [here](https://github.com/grpc/grpc/issues) – Sathi Aiswarya Oct 05 '22 at 13:41

0 Answers0