#task not executing till the end

1 messages · Page 1 of 1 (latest)

random furnace
#

So I have a task whcih should create some calendar slots. Now its not important to understand the code. But i think I am creating a task as it should but task like cancels randomly at some point. Also the the terminal logs all want added in the code but the dashboard does not, really wierd.

pine stone
#

Ok I think you're doing async code inside forEach which doesn't work in JavaScript.

It's a really common bug, and it's incredibly annoying that they let you label it with the async word and TypeScript doesn't tell you it doesn't work.

Sentry did a good write up of this: https://sentry.io/answers/are-there-any-issues-with-using-async-await-with-foreach-loops-in-javascript/

Sentry

The Problem Consider the following JavaScript code: At first glance, this code appears straightforward. We retrieve a set of request objects, use a forEach…

#

So the reason this is failing is because it's not actually waiting for stuff properly. The end of the run function is being reached and then we shut the server down.