i have this code. i'm looping through array and creating promise which contains multiple await functions. after all functions are finished i'm resolving for item and returning promise. but i'm getting error that
TypeError: Chaining cycle detected for promise #<Promise>
const run = async () => {
let res = await db.query(query);
let items = res.rows;
const promises = items.map((item, i) => {
try {
const one = new Promise(async (resolve, reject) => {
const product = await stripe.products.create(...);
const session = await stripe.checkout.sessions.create(...);
const price = await stripe.prices.create(...);
await saveInvoice(...);
let user = await someF(...);
await someF2(..,..,..,);
resolve(item);
});
return one;
} catch (error) {
console.log(error);
process.exit();
}
});
await Promise.all(promises).then(() => {
process.exit();
});
}
run();