Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Silently crashes process on require() errors #331

Closed
steve-gray opened this issue Feb 1, 2016 · 9 comments
Closed

Silently crashes process on require() errors #331

steve-gray opened this issue Feb 1, 2016 · 9 comments

Comments

@steve-gray
Copy link
Contributor

Hello,

The swagger-router when dynamically loading controllers during startup does not log any information regarding what happened. This causes the application process usually to exit silently under the following scenarios:

  • Syntax error in controller (or any file required at any-depth from a controller)
  • Any init-time/module-load time exceptions thrown on the require path.

This *_may *_be related to the issues in #327, but has cost myself and my team a lot of time trying to figure out that the real issue was a downstream service connection not being able to start, causing a module to fail to load, etc etc.

-Steve

@whitlockjc
Copy link
Member

Have you tried running with the debug environment variables set? All errors encountered should be logged. It's documented here: https://github.com/apigee-127/swagger-tools/blob/master/docs/Middleware.md#swagger-middleware-debugging

@whitlockjc
Copy link
Member

Yes, this is related to #327.

@steve-gray
Copy link
Contributor Author

Yes: all that happens is that you see the line about 'Controllers:' and then it silently dies. That's why this fix. I've tested this fix with and without DEBUG set and confirmed the outputs from my examples are as expected.

Sent from my iPhone

On 1 Feb 2016, at 11:46, Jeremy Whitlock notifications@github.com wrote:

Have you tried running with the debug environment variables set? All errors encountered should be logged. It's documented here: https://github.com/apigee-127/swagger-tools/blob/master/docs/Middleware.md#swagger-middleware-debugging


Reply to this email directly or view it on GitHub.

@steve-gray
Copy link
Contributor Author

Though what I've just realised is that the spacing has gone mental when copy pasting from editor to editor >_<

Sent from my iPhone

On 1 Feb 2016, at 11:47, Jeremy Whitlock notifications@github.com wrote:

Yes, this is related to #327.


Reply to this email directly or view it on GitHub.

@whitlockjc
Copy link
Member

I appreciate the help. When you fix the formatting, just update the PR.

@steve-gray
Copy link
Contributor Author

It's fixed now. If you could let me know whenever this eventually makes it into an NPM release, I'd be much appreciative as it means we can ditch our locally patched version :)

@whitlockjc
Copy link
Member

You got it. I really appreciate your help.

@steve-gray
Copy link
Contributor Author

It's the least I could do. For what its worth, I've also put up an example project I'm using when teaching people about microservices using swagger. You can find it at:

https://github.com/node-templates/base-microservice-swagger

It basically uses more or less every bit of middleware you've produced, though I'd be interested to see an example of how I can add API-key support to it if you get a moment, because I struggle slightly with how the security middleware works.

@whitlockjc
Copy link
Member

This has been resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants