Api service works in debug, but not in production

I have a API service in JS that works in debug mode, but when is deployed in production doesn’t work.

I have checked the log in both modes (debug and prod) and writes the same info, also I have checked references and use a try block around all my code and there is no errors.

What could be the problem?

sendMessage(devices, source, payload){
        return new Promise(async (resolve, reject) => {
            try{
                ...
            }catch (e) {
                console.log(e)
            }

        }).catch(e => console.log(e))
    }

Could you please provide the output of coderunner when you run npm run deploy ?

Also, what happens when you invoke the API service? Is there an error? Do you have log at the very begging of the API service method to indicate the execution got in there?

this is the deploy’s log:

dcastaneda@Darios-MacBook-Pro XXIO__JS_default_coding % npm run deploy

> XXIO-servercode@1.0.0 deploy /Users/.../Backendless/XXIO__JS_default_coding
> coderunner deploy

17:37:46.328 CodeRunner(tm) Backendless JavaScript CodeRunner v6.1.6
17:37:46.333 Copyright(C) 2021 Backendless Corp. All rights reserved. 
17:37:46.337 Run Options is:  {
  "backendless": {
    "apiServer": "https://api.backendless.com",
    "msgBroker": {
      "host": "cl.backendless.com",
      "port": 6379
    },
    "public": {
      "fileDownloadUrl": "http://localhost:9000",
      "publicAPIUrl": "http://localhost:9000",
      "internalAPIUrl": "https://api.backendless.com"
    },
    "apiUrl": "https://api.backendless.com",
    "repoPath": "/var/lib/backendless/repo/"
  },
  "app": {
    "id": "7E819124-27B5-85D2-FF77-9FB70FF33800",
    "apiKey": "137A288F-XXXXXXXXXXXXXXXX-539D06CB347A",
    "model": "default",
    "exclude": [
      "package.json",
      "coderunner.json",
      "README.md",
      "servercode.iml",
      "servercode.ipr",
      "servercode.iws"
    ]
  },
  "workers": {
    "cache": false,
    "concurrent": 4,
    "heartbeat": {
      "interval": 5,
      "timeout": 10
    }
  },
  "sandbox": false,
  "verbose": false,
  "compression": {
    "debug": false,
    "prod": false
  }
}
17:37:46.337 IMPORTANT!
The business logic code will be deployed to model "default".
Any business logic which is already deployed on the server in that model
will be removed and replaced with the code from your current project.
If this is an undesired behavior, stop now and set a different deployment model
either by using the --model argument or changing the model name in coderunner.json.
Would you like to continue? (Y/N)Y
17:37:48.402 Building Model..
17:37:48.873 ServerCode Model built in 471ms
17:37:48.873 Event handlers (5):
17:37:48.874   persistence.beforeRemove (product, async) (handlers/persistence/product/beforeRemove.js)
17:37:48.874   persistence.afterCreate (product_asset, async) (handlers/persistence/product_asset/afterCreate.js)
17:37:48.874   persistence.afterRemove (product_asset, async) (handlers/persistence/product_asset/afterRemove.js)
17:37:48.874   user.afterLoginAsGuest (async) (handlers/user/afterLoginAsGuest.js)
17:37:48.874   user.afterRegister (async) (handlers/user/afterRegister.js)
17:37:48.874 Custom Types (3):
17:37:48.874   Product (models/product.js)
17:37:48.874   Product_asset (models/product_asset.js)
17:37:48.874   Wikitude (models/wikitude.js)
17:37:48.874 Services (4):
17:37:48.874   PageService (services/page-service.js)
17:37:48.874   ProductService (services/product-service.js)
17:37:48.874   UserService (services/user-service.js)
17:37:48.874   WikitudeService (services/wikitude-service.js)
17:37:48.875 Preparing app zip file for deployment..
17:37:49.207 70 files added into deployment archive
17:37:49.245 Publishing Model to server
17:37:52.321 Successfully published

There is no error, I have catch blocks for promise and inside of promise

Someone from our node.js team will need to chime in, but by the looks of it, your method immediately returns Promise without waiting for it to complete. As a result, the method invocation ends right there.

I’ve added an await to the promise, but I have the same behavior, in debug mode works, but the deployed version does not.

async sendMessage(devices, source, payload){
        return await new Promise(async (resolve, reject) => {
            try{
                ...
            }catch (e) {
                console.log(e)
            }

        }).catch(e => console.log(e))
    }

Hello @Dario_Castaneda

Could you please describe what exactly doesn’t work, do you have any errors?
How can we reproduce the issue?

Regards, Vlad