InversifyJS icon indicating copy to clipboard operation
InversifyJS copied to clipboard

postConstruct inconsistency for sync and async

Open ehsan2003 opened this issue 2 years ago • 0 comments

Expected Behavior

post construct should act consistently for both async and sync post constructor functions

Current Behavior

it reshapes the errors of the synchronous post constructor while leaving the errors of async ones as is

Possible Solution

change the code that runs the post constructor and add an await like

Steps to Reproduce (for bugs)

  1. create two separated classes one with synchronous and one with asynchronous postConstructor
  2. throw error from both of them
  3. see how they are different

Context

Well to be honest my problem is way worth I have a very very strange usecase and in my specific situation there are unhandled rejections after an error comes out of the method with postConstruct decorator but I can't really reproduce it to show how it is and I think fixing this issue will fix that too

Your Environment

  • Version used:6.0.2
  • Environment name and version (e.g. Chrome 39, node.js 5.4): node 18.17.1
  • Operating System and version (desktop or mobile): linux ( nixos

Stack trace

ehsan2003 avatar Oct 25 '23 11:10 ehsan2003