A newer version of this documentation is available.

View Latest

Troubleshooting and Best Practices


      What happens when more Workers are allocated for a Function?

      Couchbase Server for a specific Function limits the maximum number of workers to 10. This upper limit is configured for system optimization purposes. In the Function definition, if the number of workers exceeds the set threshold, then the system automatically generates a warning message. However, the warning message does not prevent the Function deployment.

      Warning Message: "There are <number_of_workers> eventing workers configured to run. System performance may be impacted."

      Can this release of Couchbase Server process cURL commands?

      Support for cURL commands in Functions is for demo purposes. Ensure not to use cURL commands in your production environment.

      The system generates a warning message. However, the warning message does not prevent the Function deployment.

      Warning Message: "Handler <function_name> uses Developer Preview features. Do not use in production environments."

      cURL commands are a Developer Preview feature intended for development purposes only, do not use them in production; no Enterprise Support is provided for Developer Preview features.

      When should developers use the try-catch block in Function handlers?

      As a best practice, while programming the Function handler code, for basic error handling and debugging operations, it is recommended that application developers use the try-catch block.

      Before deployment, Couchbase Server verifies the Function handler code. Only valid Functions get deployed. Using the log option within a try-catch block, you can record errors. These error logs get stored in the application log file. By default, JavaScript runtime errors get stored in the system logs. Unlike system logs, troubleshooting and debugging operations are easy when you use the try-catch block and application log options.

      During runtime, Application logs, by default, do not capture any handler code exceptions. To log exceptions, it is recommended to encapsulate your code in a try-catch block.

      A sample try-catch block is provided for reference:

      function OnUpdate(doc, meta)
        log('document', doc);
        try {
          var time_rand = random_gen();
          dst_bucket[meta.id + time_rand] = doc;

      What are bucket allocation considerations during a Function definition?

      Function handlers can trigger data mutations. To avoid a cyclic generation of data changes, ensure that you carefully consider the below aspects while specifying source and destination buckets:

      • Avoid infinite recursions. If you are using a series of handlers, then ensure that destination buckets to which event handlers perform a write operation, do not have other Function handlers configured to listen and track data mutations.
        Couchbase Server can flag simple infinite recursions. However, in a long chain of source and destination buckets with a series of handlers, a complex infinite recursion condition may occur. As a developer, carefully consider these cases.

      • As a best practice, ensure that buckets to which the Function handler performs a write operation do not have other handlers configured for tracking data mutations.

      In the cluster, I notice a sharp increase in the Timeouts Statistics. What are my next steps?

      When the Timeout Statistics shows a sharp increase, it may be due to two possible scenarios:

      • Increase in execution time: When the handler execution time increases, the Function execution latency gets affected, and this in turn, leads to Function backlog and failure conditions.

      • Script timeout value: When the script timeout attribute value is not correctly configured, then you encounter timeout conditions frequently.

      As a workaround, it is recommended to increase the script timeout value. Ensure that you configure the script timeout value after carefully evaluating the execution latency of the Function.

      As a best practice use a combination of try-catch block and the application log options. This way you can monitor, debug and troubleshoot errors during the Function execution.