Ensures full cleanup of server side connection close
Clean clean-up
Promise.allSettled ensures that as much cleanup as possible is done - even if some fails.
This method might be a requirement for here also where the first thrown error would potentially cause the lambda to shutdown before other (potentially succeeding) promises can be resolved.
Something like this could work
```js
try {
await Promise.allSettled([
Promise.resolve("Resolved!"),
Promise.reject("Rejected!")
]).then((r) =>
r.forEach(({ status, reason }) => {
if (status === "rejected") {
throw reason;
}
})
);
} catch (err) {
console.log(err);
}
```
Changes
Clean clean-up
Promise.allSettled
ensures that as much cleanup as possible is done - even if some fails.This method might be a requirement for here also where the first thrown error would potentially cause the lambda to shutdown before other (potentially succeeding) promises can be resolved.
Something like this could work
```js try { await Promise.allSettled([ Promise.resolve("Resolved!"), Promise.reject("Rejected!") ]).then((r) => r.forEach(({ status, reason }) => { if (status === "rejected") { throw reason; } }) ); } catch (err) { console.log(err); } ```