You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
8.8.2
Node.js version
v20.18.0
MongoDB server version
8.0.3
Typescript version (if applicable)
5.7.2
Description
I am using LangGraph which has a Mongo DB backed checkpoint memory, to connect it is looking for a MongoClient, so I have attempted to get the MongoClient object from Mongoose. This is the code I have so far:
import { MongoDBSaver } from '@langchain/langgraph-checkpoint-mongodb';
import { type MongoClient } from 'mongodb';
import mongoose from 'mongoose';
const client = /** @type {MongoClient} */ ( mongoose.connection.getClient() );
const mongoDBParams = {
checkpointCollectionName: 'checkpoints',
client: client,
dbName: process.env.MONGO_NAME
}
const memory = new MongoDBSaver(mongoDBParams);
Unfortunately this throws the following error:
ERROR in /usr/local/quoterion/server/graphs/email_quote.ts
18:32-45
[tsl] ERROR in /usr/local/quoterion/server/graphs/email_quote.ts(18,33)
TS2345: Argument of type '{ checkpointCollectionName: string; client: mongoose.mongo.MongoClient; dbName: string; }' is not assignable to parameter of type 'MongoDBSaverParams'.
Types of property 'client' are incompatible.
Property 'timeoutMS' is missing in type 'import("/usr/local/quoterion/server/node_modules/mongoose/node_modules/mongodb/mongodb").MongoClient' but required in type 'import("/usr/local/quoterion/server/node_modules/mongodb/mongodb").MongoClient'.
It seems the 'MongoClientreturned is not compatible as its parameters are missing thetimoutMS`. In the Current MongoDB driver I can see this property but the version of the documentation on the Mongoose reference links to am older version that does not have this property (maybe a v4 version?). AFAIK LangGraph is using a v6.11.0 Mongo Driver.
Note in the rest of my code the mongoose driver is already up and running ok, hence I just thought I could get the underlying MongoClient.
Steps to Reproduce
Install LangGraph.JS, TypeScript, Mongoose and the MongoDB Types. Create a typescript file with the above and attempt to build.
Expected Behavior
This should build and run.
The text was updated successfully, but these errors were encountered:
Can you run npm list mongodb? It looks like you have 2 versions of the MongoDB node driver installed: 1 as a top level dep in package.json and one that Mongoose uses.
vkarpov15
added
the
help
This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
label
Nov 26, 2024
@vkarpov15 hi, I had installed a mongoldb library in order to try casting the type in case it was necessary. I removed the library I had installed and reverted the client assignment line to be:
Prerequisites
Mongoose version
8.8.2
Node.js version
v20.18.0
MongoDB server version
8.0.3
Typescript version (if applicable)
5.7.2
Description
I am using LangGraph which has a Mongo DB backed checkpoint memory, to connect it is looking for a
MongoClient
, so I have attempted to get theMongoClient
object from Mongoose. This is the code I have so far:Unfortunately this throws the following error:
It seems the 'MongoClient
returned is not compatible as its parameters are missing the
timoutMS`. In the Current MongoDB driver I can see this property but the version of the documentation on the Mongoose reference links to am older version that does not have this property (maybe a v4 version?). AFAIK LangGraph is using a v6.11.0 Mongo Driver.Note in the rest of my code the mongoose driver is already up and running ok, hence I just thought I could get the underlying
MongoClient
.Steps to Reproduce
Install LangGraph.JS, TypeScript, Mongoose and the MongoDB Types. Create a typescript file with the above and attempt to build.
Expected Behavior
This should build and run.
The text was updated successfully, but these errors were encountered: