-
Notifications
You must be signed in to change notification settings - Fork 100
Closed
Description
Just want to double check this code is doing what's expected.
Line 164 in ade41b2
| // Ensure devicePool.release is called for both providers even if one rejects. |
// Ensure devicePool.release is called for both providers even if one rejects.
await Promise.all([
this.provider?.then(x => devicePool.release(x)),
this.mismatchedProvider?.then(x => mismatchedDevicePool.release(x)),
]);It will call devicePool.release on both. It will not wait before proceeding as Promise.all continues as soon as one promise rejects.
Is that fine that it doesn't wait? If we want it to wait then I think you'd need something like
// Ensure devicePool.release is called for both providers even if one rejects.
const results = await Promise.allSettled([
this.provider?.then(x => devicePool.release(x)),
this.mismatchedProvider?.then(x => mismatchedDevicePool.release(x)),
]);
const rejected = results.find(result => result.status === 'rejected');
if (rejected) {
throw rejected.reason;
}Metadata
Metadata
Assignees
Labels
No labels