3 ms·
Promise.allSettled(…x) :)
by EthicalSimilar 3y ago
Promise.allSettled(…x) :)
- moring 3y agoThis doesn't solve the issue at all, does it? If Promise.all() is never reached, neither is Promise.allSettled().
- simonbarker87 3y agoallSettled() returns an array of objects for each promise result that tells you if it has been rejected or resolved, so as long as all the promises reject or resolve then it should solve the problem I think?
- Timon3 3y agomoring is describing an issue where the creation of the promise itself fails, which means Promise.all/Promise.allSettled is never called.
- evanreichard 3y agoUse the second pattern with `.allSettled` but map it with an async function. const result = await Promise.allSettled(elements.map(async x => someAsyncFunction3(computeArg3(x))));
- Timon3 3y agoYep, that works fine: https://www.typescriptlang.org/play?target=8#code/IYZwngdgxgBAZgV2gFwJYHsIxOgtgUwEFxoAxJKNTACmACcBzALhggVwCN86BKGAbwBQMGHXzIEdLMADuwVMhj0GggL6DBiFBixQ8ABwTIijWoxZtO3HhfZc6A4aPGTpjGAGoYARjUbQkLBalDrYeEQkUOTamADqCgAWAKJ0dOh0ZsysdtaOIsgJaTKs+MUpaRkARDgExIHRIZiVPH6aFFS6BkYmDPEF5emZtla8w-Z5MAVFJWWpg5V6uIbGhIzNrXoQIIr4ADb4BBDIIDAAvDAA2gAMADQ+dwBMALoaANy0kTDUfKcAfBObbbOEAIXbIbxnJRyBQwAAKaVwqBA+AAdMBdrsAMriZD7AAm1D2B3wRxAKNwwH0H0CMAAHmd-jUIvV2jpqItlj1qLSeLyWiJAeh9ijdugGNQxCCwd4Wk5AYpJaDkA9IbJ5Ip4Xgkaj0VicfjCftDsdyZTqdA6QywrVIg0On1knMMhzuqtxTy+XLMDhhaLxYqwQ9ZQLvQr8FLkABmVXQjUI7VojHY5C4-AEonGskUqkBC30v7W5lkVk0F0rRgOgYZD28r1bIWov0S8NKyMtVQ8b5AA https://www.typescriptlang.org/play?target=8#code/IYZwngdgxg...
- EthicalSimilar 3y agoYes, it works fine. As mentioned below just pass an asynchronous function and it’ll catch it.