business logic working on debug but not on production

Hi, I have a custom business logic which is supposed to be triggered after an insert operation in a given table. After insert, it checks is the just added record has a filed with a specific value and, in that, case updates the user.

It works perfectly in when the script in in debug mode, but it does not work when it is in production.
I know that there is a 5 seconds executions limits, but I think it’s not possible that a record read and update takes more than that

Hi Simone,
Please share your app ID and also provide some test request with expected results so that we could reproduce the problem.

application id: “53D90AB4-154F-B2F1-FF25-F32F40003300”

TEST: make a post request to “order” table with the following payload

{
“coupon”:“APP_ARR2017”
}

EXPECTED RESULT: the field “couponConsumed” in the user table for the user who made the order should become true

ACTUAL RESULT IN PRODUCTION: the field “couponConsumed” in the user table for the user who made the order if false

ACTUAL RESULT IN DEBUG: the field “couponConsumed” in the user table for the user who made the order if true

Do you have any logs inside of your handler? Try adding them and see whether it’s launched and if yes, where it stops.

I have many console.log() calls in the script, and in debug I can see all of them

How can I see logs for production scripts?

You should be able to find them in Log Management section, but I see there are no entries there. Have you tried redeploying the handler? Also, do other handlers execute as expected?

the handler actually is invoked, but is not fully executed. It should send an email, and eventually update the user object. But it just sends the email.

I don’t know what you mean for the log that should be present in log managment, what does it mean?

I think you should change your console.log statements to Backendless Logging API in order to see the logs.

where should I see the logs after that?

At Manage -> Log Management tab.

Hi, I am using this Backendless.Logging.setLogReportingPolicy(0, 1); to write immediately the logs for a fast debugging, but the logs take time to appear, what am I doing wrong?

How much time? The process is never real-time, “write immediately” means that the task to write the logs is launched immediately, but it’s still asynchronous.

How long does it approximatelly takes?

A couple of minutes max, I think. Usually a few seconds.

is it a good practice to delete the log file if I want to start from a clean log or does it create problems?

Sure, you may delete it anytime, it will be recreated once new logs come in.

I just noticed a strange log during debug: Integrity violation. Unknown event id: [32767]

What does it mean?

Does it come from server or CodeRunner?

code runner