mjwheatley / graphql-mongodb-subscriptions

A graphql-subscriptions PubSub Engine using MongoDB
MIT License
11 stars 4 forks source link

Getting Tailable cursor.on error from the library in our Application Logs. How can i resolve that issue ? #44

Open dhruva2392 opened 4 months ago

dhruva2392 commented 4 months ago

This is how we are creating the pubsub.

import { databaseName, connectionString } from '../config.js'; import { MongoClient } from 'mongodb'; import { MongodbPubSub } from 'graphql-mongodb-subscriptions'; import { supplyOrderCollection } from '../config.js';

export const client = new MongoClient(connectionString);

export const db = client.db(databaseName); const PubSubMongoDbOptions = { connectionDb: db, channelName: databaseName, }; export const pubsub = new MongodbPubSub(PubSubMongoDbOptions);

export const watchSupplyOrderCollection = db.collection(supplyOrderCollection);

mjwheatley commented 4 months ago

Please review this other issue and see if that helps with your setup

https://github.com/mjwheatley/graphql-mongodb-subscriptions/issues/43

dhruva2392 commented 3 months ago

This is a different issue. The setup works in production for about 6-10 days and then we are getting tailableCursor.on('error') in all the pods and subscription stops working.

We can see the subscribe logs but not the publish logs after this error.

This is something to do with capped collection that is being created by graphql-mongodb-subscriptions

dhruva2392 commented 3 months ago

@mjwheatley Do you have any suggestions for me ?

This error is happening due to the mubsub capped collection created by the module.

mjwheatley commented 3 months ago

This is the dependency package that actually creates the tailable cursor.

https://github.com/mjwheatley/mongopubsub/blob/master/src/channel.ts

Line 134 is the console.error() messages that you may be seeing. Does it print out the error object and provide any additional information about the error?

dhruva2392 commented 3 months ago

MicrosoftTeams-image (3)

@mjwheatley All we see is that in our logs.

As that error is coming from the module. We don't have have much information on what is the root cause and how to resolve it

mjwheatley commented 3 months ago

We really need to find out what the actual error is. Not sure how your application is being packaged and ran, but you could potentially go into the node_modules folder and find the error message and modify t so that it shows more info in your logs.

image

You could could change it to something like

console.error(`tailableCursor.on('error') Error Message: ` + error.message);
mjwheatley commented 3 months ago

It seems like it might be a connection issue. Perhaps setting timeout or noCursorTimeout on the FindOptions to false.

image

Are you experiencing any connectivity issues with the Mongo connection itself or is it just the tailable cursor?