Problem description: In the JSONata library, the evaluate function does not properly handle errors when a callback function is used. The error is thrown without being returned to the callback function, causing unhandled errors. It is expected that the error should be returned in the callback function. The problematic code can be found here:
Inconsistent behavior: The documentation and this comment suggests using a callback function to enable asynchronous mode. However, during testing, it seems that the asynchronous function gets evaluated regardless of whether a callback function is used or not.
Reproduction Steps:
Use the evaluate function with a callback function to handle the result asynchronously.
Trigger an error condition that should result in an error being returned.
Observe that the error is not returned through the callback function, but instead thrown directly.
Expected Behavior:
When a callback function is used, the evaluate function should return the error through the callback function instead of throwing it directly. Additionally, the asynchronous behavior should only take effect when a valid callback function is provided.
Problem description: In the JSONata library, the
evaluate
function does not properly handle errors when a callback function is used. The error is thrown without being returned to the callback function, causing unhandled errors. It is expected that the error should be returned in the callback function. The problematic code can be found here:https://github.com/jsonata-js/jsonata/blob/d7790e873194bfebc3719ab08983b5a58fa2848b/src/jsonata.js#L2094-L2141
Inconsistent behavior: The documentation and this comment suggests using a callback function to enable asynchronous mode. However, during testing, it seems that the asynchronous function gets evaluated regardless of whether a callback function is used or not.
Reproduction Steps:
evaluate
function with a callback function to handle the result asynchronously.Expected Behavior:
When a callback function is used, the
evaluate
function should return the error through the callback function instead of throwing it directly. Additionally, the asynchronous behavior should only take effect when a valid callback function is provided.Environment: