I am getting timeouts intermittently for my User.afterRegister business logic. It basically queries the user that was just created, creates one object of a custom class and saves, then creates another object of a custom class and saves. How can this take more than 5 seconds?
This usually shouldn’t take 5 seconds to execute, but it’s possible if the server experience some kind of load or network issues.
In order to investigate your problem we need the steps to reproduce it.
It is a redundant operation to query just created user in afterRegister event handler since you already have it in the req.user property
This cannot be easily reproduced. It’s an intermittent issue. I believe that eventually even the simplest piece of code would timeout. It’s just unfair to have your code timeout if the server is under increased load. These timeouts can cause serious issues with database consistency. I used to have this exact same problem with Parse as well. Even simple pieces of code would timeout in Cloud Code sometimes and my database would become inconsistent (e.g. an afterSave that increments a counter in another object would timeout and my counters would get wrong).
@Vitaly Vengrov: I can’t remember exactly now what happened but req.user doesn’t seem to be a complete user object. I need to create another object (user Settings) after registering and this object has a reference to the user and if I use req.user the save operation fails.
Unfortunately, since the Cloud Backendless version is free, there are no guarantees that your code will never experience a timeout (thought we really try to reduce the possibility as much as possible).
You may gain more confidence in service’s performance in Managed Backendless version. More information by email: email@example.com