Open dhruva2392 opened 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
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
@mjwheatley Do you have any suggestions for me ?
This error is happening due to the mubsub capped collection created by the module.
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?
@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
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.
You could could change it to something like
console.error(`tailableCursor.on('error') Error Message: ` + error.message);
It seems like it might be a connection issue. Perhaps setting timeout
or noCursorTimeout
on the FindOptions
to false
.
Are you experiencing any connectivity issues with the Mongo connection itself or is it just the tailable cursor?
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);