Rocket.Chat.Apps-engine icon indicating copy to clipboard operation
Rocket.Chat.Apps-engine copied to clipboard

Unable to use setTimeout() in Rocket.Chat App

Open Chirtep opened this issue 2 years ago • 4 comments

In our dip-application we're using setTimeout() and catching errors like this (pay attention to the top line):

setTimeout

As we understand, timers support was added earlier in the apps-engine (around 2021). But now, as we can see, it is not possible to get setTimeout. Is there any way to solve this problem?

Chirtep avatar Feb 01 '23 12:02 Chirtep

@d-gubert @murtaza98 hey! Can you check that please?

ankar84 avatar Feb 01 '23 12:02 ankar84

We asked earlier with this PR to enable timers.

shevchukma avatar Feb 01 '23 14:02 shevchukma

setTimeout is intentionally disabled because once you do that then you lose scope and context inside of the App and the logs. The recommended route is to use promises as the Apps Engine tracks the context based on the initial promise. @d-gubert can correct me if I am wrong, but I doubt support will be added.

graywolf336 avatar Feb 01 '23 15:02 graywolf336

setTimeout is intentionally disabled because once you do that then you lose scope and context inside of the App and the logs. The recommended route is to use promises as the Apps Engine tracks the context based on the initial promise. @d-gubert can correct me if I am wrong, but I doubt support will be added.

@graywolf336 we need timers for our delay method:

промис

In our case, it's necessary to resolve promise with a certain delay, so setTimeout(), as we see, is the best way to realize our goals.

Chirtep avatar Feb 02 '23 07:02 Chirtep