Hello,
I’m using “couchbase”: “^4.3.1” in my Node.js application. We use Couchbase as a caching mechanism (2 hours) for some data received from another endpoint.
I observed that once a document expires (or it doesn’t exist), when querying non-existent keys from the primary node, I receive DocumentNotFoundError as expected. However, based on the current code, we’re also querying the replicas 2 times (using getAnyReplica). For the same non-existent keys, I consistently receive DocumentUnretrievableError from the replicas.
No matter if I call the replica with a fresh key or an expired one, the response from getAnyReplica is the same error:
DocumentUnretrievableError: document unretrievable] {
cause: [Error: document_irretrievable (102)] {
ctxtype: 'key_value',
code: 102,
id: 'super-random-not-found-key',
opaque: 20,
cas: Cas<0>,
status_code: 1,
enhanced_error_info: undefined,
retry_attempts: 0,
retry_reasons: []
},
context: KeyValueErrorContext {
status_code: 1,
opaque: 20,
cas: Cas<0>,
key: undefined,
bucket: undefined,
collection: undefined,
scope: undefined,
context: '',
ref: ''
}
}
I want to modify the code a little bit to make it handle the responses more gracefully and I’m in a dilemma if doing something like this if (error instanceof DocumentNotFoundError || error instanceof DocumentUnretrievableError) {
would be a correct approach.
Is throwing DocumentUnretrievableError
expected? If not, how would you recommend I handle DocumentUnretrievableError?
Thank you!