I am facing a very strange issue. As soon as I updated my node to node 16 from 14 my tests stopped working and I get a complain like this:
Error: 
    at /src/api/v1/datastore/SearchesDatastore.ts:109:25
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
And my code the line it shows is:
  public async isRemovalNeeded() {
    try {
      this._logger.debug({message: `Checking if any design doc removal needed.`});
      const designDocsName = getDesignDocLists(this.designDocsPath);
      const allDesignDocs = await this._db.list({
        include_docs: true,
        startkey: "_design/",
        endkey: "_design0"
      });
      const toBeRemoved = allDesignDocs.rows.
        filter((row: any) => !designDocsName.includes(row.id.replace("_design/", "")));
      return toBeRemoved.length > 0;
    } catch (e) {
      this._logger.warn({ message: "Failed to retrieve list of documents." });
      this._logger.debug({ message: `Error: ${e}` });
      throw new Error(errors.ERROR_GETTING_DB_LIST.message);
    }
  }
just to test I ran the same thing with node 14 and it passed with this warning
(node:22352) UnhandledPromiseRejectionWarning: Error: 
    at src/api/v1/datastore/SearchesDatastore.ts:128:19
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:22352) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 43)
(node:22352) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
so I am thinking it is because of node16 being strict for unhandled promises but in my code I Cannot see any unhandled promise so I am confused
any help is appreciated
Also this is how I call it :
 try {
                    this._loggingService.debug({message: `Checking to see if current pod is a leader`});
                    const isLeader: any = await this._consensusService.isLeader();
                    
                    this._loggingService.debug({message: `current Pod checked for leading and isLeader is: ${isLeader}`});   
                    const isRemovalNeeded = await this._searchesDatastore.isRemovalNeeded();
                    this._loggingService.debug({message: `check occurred to make sure if design doc removal needed and isRemovalNeeded is: ${isRemovalNeeded}`}); 
                    const isUpdateNeeded = await this._searchesDatastore.isUpdateNeeded();
                    this._loggingService.debug({message: `check occurred to make sure if design doc update needed and isUpdateNeeded is: ${isUpdateNeeded}`}); 
                    if (!isRemovalNeeded && !isUpdateNeeded) {
                        shouldWait = false;
                        this._loggingService.info({ message: "All documents are up to date" });
                    } else if (isLeader) {
                        isRemovalNeeded && await this._searchesDatastore.cleanRemovedDesignDocs();
                        isUpdateNeeded && await this._searchesDatastore.syncAllDesignDocs();
                        shouldWait = false;
                    } else {
                        this._loggingService.info({ message: "Design docs are not synced but this pod is not a leader. We need to wait for leader pod to take do the house keeping first." });
                    }
                    if (!shouldWait) {
                        this._loggingService.debug({message: `datastorewatcher is done and we are proceeding to the next step...`});
                        this.watcherFailureCount= 1;
                        resolve(true);
                        break;
                    } else {
                        this._loggingService.debug({message: `datastorewatcher is not done. We will try again after ${config.databaseWatcher.interval}.`})
                        await this.sleep(config.databaseWatcher.interval);
                    }
                } catch (e) {
                    this.watcherFailureCount++;
                    if(this.watcherFailureCount> config.databaseWatcher.toleranceLevel){
                        this._loggingService.warn({message: "App crashed and pod will die soon"})
                        reject(e);
                        break;
                    }
                    const nextIntervalToRun: number= config.databaseWatcher.interval * this.watcherFailureCount;
                    this._loggingService.warn({ message: `DataStoreWatcher failed but still failure is less than tolerance threshold: ${config.databaseWatcher.toleranceLevel}. Watcher will run again in ${nextIntervalToRun}. ${e}` });
                    await this.sleep(nextIntervalToRun);
                }
