Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous error handling in callback method is affected with v4.4.4 release #123

Closed
abhilash-sivan opened this issue Dec 6, 2024 · 3 comments

Comments

@abhilash-sivan
Copy link

Hi team,

In the latest release v4.4.4, we found an issue affecting our query execution.

Due to changes in this commit, the asynchronous behavior of query executions is affected in callback method.

@instana/collector: node:internal/process/promises:391
@instana/collector: triggerUncaughtException(err, true /* fromPromise */);

If a query execution fails, it is immediately thrown as an error, and further execution is blocked.
We don't have control over handling the failure.

scope.query(queryString, () => {
    cluster.queryIndexes().dropIndex(bucket.name, index1, () => {
        // and so on...
    });
});

We expect the failed query won't affect the current execution and the workflow continues until manually thrown like below:

scope.query(queryString, err => {
    if (err) {
        // return error
    };

    cluster.queryIndexes().dropIndex(bucket.name, index1, () => {
        // and so on...
    });
})

Handling like below doesn't work anymore:

scope.query(queryString, err => {
    if (err) {
        // do nothing, continue execution
    };

    cluster.queryIndexes().dropIndex(bucket.name, index1, () => {
        // and so on...
    });
})

As a workaround solution, we are forced to catch the returned promise and handle the error cases separately:

scope.query(queryString).catch(() => {
     // do nothing, continue execution
}).finally(() => {
 cluster.queryIndexes().dropIndex(bucket.name, index1, () => {

 });
})

This is coming from the change in PromiseHelper in the commit, Please take a look.

Thanks in advance,
Abhilash

@JesusTheHun
Copy link
Contributor

For anyone interested, I have written a TypeScript overlay to the official SDK, and that package does not have the issue introduced in 4.4.4 in the official package. It does fix the double invocation mentioned in https://jira.issues.couchbase.com/browse/JSCBC-1298 though.

Documentation: https://cbjs.dev

@thejcfactor
Copy link
Contributor

thejcfactor commented Dec 17, 2024

Hi @abhilash-sivan -- I have created JSCBC-1311 for tracking within our JIRA system. Will follow-up once the fix is made available (target is the next release v4.4.5).

@thejcfactor
Copy link
Contributor

thejcfactor commented Jan 28, 2025

Hi @abhilash-sivan -- Version 4.4.5 of the Node.js SDK has been released. v4.4.5 includes changes from JSCBC-1311 which should address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants