I have an async
function, in which I take some arguments. Based on what is passed as argument, I call another function. You can consider the structure to be something like this.
async function createTaskReminder(val) {
switch (val) {
case 1:
await call1();
case 2:
await call2();
case 3:
await call3();
}
I call this async function as following:-
const result = await Promise.all([
createTaskReminder(1),
createTaskReminder(2),
createTaskReminder(3)
]);
The async
functions called inside createTaskReminder() perform some DB queries and possibly DB updations as well.
The problem is that in the console, as well as in the DB I can see results of calling createTaskReminder(1)
only. Which means, that only the first promise is being resolved.
I tried using async.each
from the async
module as well, but that also had the same results.
This is actually a code being run as a lambda function in AWS amplify.
The results which I’ve been seeing are obtained when I mock the function using amplify mock function
. So the DB updations which I’m talking about are using DynamoDB and graphql api service to interact with it.
I also tried to take the lambda and run it separately both in my machine locally and on google colab as well, but I got the same results.
I expect all the three promises to be running to completion, but that’s clearly not the case. Can someone please help me to resolve this issue?