Getting Error: parent cluster object has been closed with Couchbase Node SDK v3
When on development I would get his error randomly and after restarting the server CB wouldn’t throw this error but now restarting also not a fix for this issue.
Error: parent cluster object has been closed
at Connection._maybeFwd (E:\project\server\node_modules\couchbase\lib\connection.js:201:13)
at Connection.query (E:\project\server\node_modules\couchbase\lib\connection.js:305:10)
at QueryExecutor.query (E:\project\server\node_modules\couchbase\lib\queryexecutor.js:111:16)
at Cluster.query (E:\project\server\node_modules\couchbase\lib\cluster.js:294:24)
at _callee6$ (E:\project\server\database\couchbase\/index.js:106:36)
at tryCatch (E:\project\server\node_modules\@babel\node\node_modules\regenerator-runtime\runtime.js:63:40)
at Generator.invoke [as _invoke] (E:\project\server\node_modules\@babel\node\node_modules\regenerator-runtime\runtime.js:293:22)
at Generator.next (E:\project\server\node_modules\@babel\node\node_modules\regenerator-runtime\runtime.js:118:21)
at asyncGeneratorStep (E:\project\server\database\couchbase\index.js:14:103)
at _next (E:\project\server\database\couchbase\index.js:16:194)
So, I have played around with the basic examples many times this week thinking about your issues, it just doesn’t happen for me. I’m wondering if you might be available to do a Zoom call and give me a better look at your project and how it’s set up, exactly how and when you are getting this error, is it only initially a problem and then the error goes away? This seems like an issue that I may not be able to solve with the given info, maybe talking live in person or if you can give us some additional information about your setup or access to the repo or something. Again I’m just not able to recreate the issue on my end. Is this a project in production or just trying out in development? Is it possible that it works on dev env but you’re getting this issue in production?
This is kind of a long shot, but maybe you are facing the same problem I had twice. We are using NestJS + Typescript + Node.js SDK 3.0.4.
Like stated earlier, I have seen a weird issue where all of the suddent the ‘parent cluster object has been closed’ is constantly thrown. Obviously, check the username and password first. But in my case, it was simply a bug in our code, but not in the code that is directly related to couchbase. I don’t know how it ended throwing that error, I assume it has something to do with the asynchronous calls.
As it was some weeks ago, I don’t remember the specifics, but in our case, we were fetching data simultaneously from Couchbase and ElasticSearch ( await Promise.all([…]) ). If something failed in the ElasticSearch query, the error message that was logged to console was ‘parent cluster object has been closed’ from couchase. I don’t know why it behaved like this, but I assume it was because the elasticsearch call failed before the couchbase call returned any data.
Anyways, it’s easy to test if the problem is really related to couchbase or if it is some weird side effect. Just add very minimalistic piece of code to the method(s) in question and return for example static data. Does it work? Good! Then add minimalistic call to the database and still return the static data. Does it still work? If it does, the problem might not be in the couchbase call, but somewhere else in your codebase. Just keep adding the code line-by-line to the method and see if that helps to debug the actual issue.