Open tshemsedinov opened 7 months ago
If await this.createDbConnection(dbType, config) will throw new DatabaseError('Failed to connect to Database') then I think the code will end up with unhandled promise rejection. Doesn't it?
@Romick2005 this error will be added to tasks but it is so unclear... that's why I'd propose to rewrite it in obvious way
https://github.com/diia-open-source/be-pkg-db/blob/0ac6f89eb7d1a961ced739c033862527caece65f/src/services/database.ts#L33-L46
Array is not obvious.
tasks
will be array of empty (undefined) promises, it makes logic of .map unclear, it is recommended to return something from map callback. The fact that Promise resolved/rejected with undefined value will return PromiseAlso it is better to use
Promise.allSettled
instead ofPromise.all
this will detect all init errors by one start of the server app.