wtfnode | Utility to help find out why Node | Runtime Evironment library
kandi X-RAY | wtfnode Summary
kandi X-RAY | wtfnode Summary
Utility to help find out why Node isn't exiting
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Dump the socket info .
- Wrap a function into a new function .
- Sets up async resources .
- Loads the actual stack traces .
- Loads SPC SDK .
- Creates a reference to the ref symbol .
- Finds the callite stack .
- Recursively copy properties to the target object .
- Wrap a global timer
- Determines the callSite .
wtfnode Key Features
wtfnode Examples and Code Snippets
Community Discussions
Trending Discussions on wtfnode
QUESTION
Brief : While writing tests in Mocha for an Express driven RESTful HTTP API using Supertest, it's known we have to require
an instance of the express app. However, this require statement is apparently the root cause for an open connection after the tests have finished and cleaned up. This is a bizarre situation and unexpected totally.
Background : The repository in question is on GitHub at sakshamsaxena/uzay [1]
The tests are typical in syntax to that recommended by Super Test itself. The request
creates the server and the callback passed to expect
closes the server. This was verified by adding console.log
lines to the library file in node_modules
. It is verified that all the connections were gracefully closed and tests passed alright. No other notification/warning anything was encountered during this, but Mocha never exited on it's own. I am well aware about the Mocha 4+ behavior and investigated this using WTFNode. On SIGINT, it was noticed[2][3] that an app
instance is still alive. Naturally, I double checked this by commenting out all tests and running the suite again with WTFNode, only to encounter the exact same message. Right now, the test has no real test, just pending tests, and 2 require statements [4] where one of those is clearly the culprit. What is happening/what am I doing wrong ?
References :
[1] : https://github.com/sakshamsaxena/uzay/
[2] :
...ANSWER
Answered 2018-Dec-20 at 06:43You are requiring the root index.js in your tests. require()
in fact do evaluate the whole js file, thus the .listen()
call will be run.
You can solve the problem by setting an environment variable that would be set only when running test, say, process.env.CI
. Then
QUESTION
I am trying to test my routes and my controllers. Here is a demo test that I wrote to see if everything is working properly.
...ANSWER
Answered 2018-Oct-31 at 15:39There was another script in the application that was instantiating sequelize. That script was not closing the connection. Added close commands there and resolved the problem. Thanks everyone for helping out :)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install wtfnode
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page