https://github.com/naugtur/promise-blocked
Detect which function blocks your eventloop
https://github.com/naugtur/promise-blocked
Last synced: 6 months ago
JSON representation
Detect which function blocks your eventloop
- Host: GitHub
- URL: https://github.com/naugtur/promise-blocked
- Owner: naugtur
- License: mit
- Created: 2016-03-13T10:34:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-13T12:18:49.000Z (over 9 years ago)
- Last Synced: 2025-02-15T07:32:15.206Z (8 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promise-blocked
Detect which function blocks your eventloop.## Usage
Tools like this are not intended for use in production (unless you're really desperate)
```javascript
var promiseBlocked = require('promise-blocked')
promiseBlocked(Promise, {
report: function reporter(rep) {
console.log(rep) //or send to logs
}
})
```All functions passed to `.then` will be measured for their execution time. Functions with execution time over 10ms will be reported to you:
```
slow function (202ms) signature:'function block1() {' at blockingChain1 (test/index.js:15:24) at shouldReportBlockingFunctionPassedToThen (test/index.js:52:5) at Object. (test/index.js:57:3)
```### Using with bluebird
To be able to extend bluebird 3.x
```javascript
var Promise = require("bluebird/js/release/promise")();
promiseBlocked(Promise, {
...
```## TODO
* bluebird support
* cover more methods than just `.then`