Bucket shutdown on nodejs SDK

I am having an issue with your SDK which is really irregular.

You throw the process with the “shutdown” bucket error. Now I know about the bucket.on(‘error’, callback) method but it doesn’t help me for two reasons:

  1. you seem to throw it even if the connections succeed. I placed that on my code and was unable to upload my server since you keep throwing errors to that callback.

  2. I don’t wish to have a callback for errors thrown, I wish to get the error upon an actual operation and use a given callback I use for that operation which allows me to handle the error differently depending on context.

The error is probably thrown because I have internet issues.
I emphasis: My issue is not that the error occur but the way you throw it and don’t let me handle it gracefully.

I hope for a proper solution. Thank you

Hey @tzali,
That particular error is thrown rather than sent via callback as it only occurs in a particular case that indicates that the user has not done their due-diligence with handling errors. In this case, it occurs only when the user has initiated a Couchbase connection that failed, and only after the connect/error event has been dispatched. You should be waiting for your Couchbase connection to be established before performing operations.
Cheers, Brett

You are wrong about this brett

The situation is that the bucket’s connection exists but then my internet goes out.
At the time of the connection the bucket opens and doesn’t throws an error but then it goes dead and the error is thrown only after I attempt the operation.

secondly I would love to hear how openBucket throws errors to callback since per documentation it doesn’t receive one as parameter

Hey @tzali,
openBucket does not directly take a callback, however you are able to subscribe to the ‘connect’ or ‘error’ events on the returned object to allow you to receive notifications about the status of that connection.
Just to clarify, you are saying that you receive a ‘connect’ event from the bucket (indicating that it has successfully connected), then sometime in the future it is throwing the ‘shutdown bucket’ error for an operation (but you have no called shutdown).
Cheers, Brett

I’m saying something worse

I’m saying that the error is thrown sometime in the future. Meaning that everything will work fine until it doesn’t.
The error might throw after several operations executed successfully (and it’s not my code because we are talking about the exact same operation every time).

so it goes like this:
connect to bucket
make a get operation - success
make a get operation - success
make a get operation - success
make a get operation - success
make a get operation - Shutdown bucket, throws error, bye bye my server.

since the get operation is an async operation it obvious that I can’t in a right mind wrap it in a try-catch nor would I consider it a good practice