medusa icon indicating copy to clipboard operation
medusa copied to clipboard

Log error if config file fails to load

Open magnusdr opened this issue 2 years ago • 1 comments

This improves the developer experience.

If you add throw new Error("You need to provide a JWT_SECRET") inside medusa-config.js, you would get the following error:

TypeError: Cannot read properties of undefined (reading 'plugins')

Which is somewhat confusing at first sight.

I'm using zod to validate that required environment variables is set, and the errors are quite descriptive, so exposing them would be nice.

Maybe it would be better to not wrap the code in try catch block in the first place, since the catch block really doesn't do anything.

magnusdr avatar Jun 14 '22 15:06 magnusdr

@olivermrbl This pull request seems Ok. I think it only needs to be merged.

gefgu avatar Sep 14 '22 23:09 gefgu

I see this is not fixed somehow, my errors thrown inside medusa-config.js now gets printed out 👌

I'll close this PR then

magnusdr avatar Nov 25 '22 21:11 magnusdr