{"_id":"make-promises-safe","_rev":"903824","name":"make-promises-safe","description":"Crash or abort if you get an unhandledRejection or multipleResolves","dist-tags":{"latest":"5.1.0"},"maintainers":[{"name":"matteo.collina","email":""}],"time":{"modified":"2021-09-20T13:46:38.000Z","created":"2017-06-19T16:27:42.131Z","5.1.0":"2019-10-02T16:28:44.304Z","5.0.0":"2019-03-21T09:45:44.458Z","4.0.0":"2018-11-20T14:25:57.588Z","3.0.0":"2018-11-01T09:29:53.515Z","2.0.0":"2018-10-25T17:42:25.626Z","1.1.0":"2017-06-22T21:57:13.971Z","1.0.1":"2017-06-19T16:34:02.475Z","1.0.0":"2017-06-19T16:27:42.131Z"},"users":{},"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"repository":{"type":"git","url":"git+https://github.com/mcollina/make-promises-safe.git"},"versions":{"5.1.0":{"name":"make-promises-safe","version":"5.1.0","description":"Crash or abort if you get an unhandledRejection or multipleResolves","main":"make-promises-safe.js","scripts":{"test":"standard | snazzy && tap test.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/make-promises-safe.git"},"keywords":["promise","promises","safe","unhandled","rejection","unhandledRejection"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/make-promises-safe/issues"},"homepage":"https://github.com/mcollina/make-promises-safe#readme","devDependencies":{"pre-commit":"^1.2.2","sinon":"^7.5.0","snazzy":"^8.0.0","standard":"^14.3.1","tap":"^12.5.2"},"gitHead":"6a4b6ba8c818538abe1eb9eb89861c624056686b","_id":"make-promises-safe@5.1.0","_nodeVersion":"10.16.3","_npmVersion":"6.11.3","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"dd9d311f555bcaa144f12e225b3d37785f0aa8f2","size":2868,"noattachment":false,"key":"/make-promises-safe/-/make-promises-safe-5.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-promises-safe/download/make-promises-safe-5.1.0.tgz"},"maintainers":[{"name":"matteo.collina","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-promises-safe_5.1.0_1570033724113_0.2600141202305517"},"_hasShrinkwrap":false,"publish_time":1570033724304,"_cnpm_publish_time":1570033724304},"5.0.0":{"name":"make-promises-safe","version":"5.0.0","description":"Crash or abort if you get an unhandledRejection or multipleResolves","main":"make-promises-safe.js","scripts":{"test":"standard | snazzy && tap test.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/make-promises-safe.git"},"keywords":["promise","promises","safe","unhandled","rejection","unhandledRejection"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/make-promises-safe/issues"},"homepage":"https://github.com/mcollina/make-promises-safe#readme","devDependencies":{"pre-commit":"^1.2.2","snazzy":"^7.0.0","standard":"^10.0.2","tap":"^10.3.3"},"gitHead":"f33e8861dd697434adf6bd845d6928ae1396e7a0","_id":"make-promises-safe@5.0.0","_nodeVersion":"10.15.2","_npmVersion":"6.9.0","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"a42b6d9cebfa1642fc3a5bdb4e583dce35f2689d","size":2631,"noattachment":false,"key":"/make-promises-safe/-/make-promises-safe-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-promises-safe/download/make-promises-safe-5.0.0.tgz"},"maintainers":[{"name":"matteo.collina","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-promises-safe_5.0.0_1553161544339_0.4782980241396433"},"_hasShrinkwrap":false,"publish_time":1553161544458,"_cnpm_publish_time":1553161544458},"4.0.0":{"name":"make-promises-safe","version":"4.0.0","description":"Crash or abort if you get an unhandledRejection or multipleResolves","main":"make-promises-safe.js","scripts":{"test":"standard | snazzy && tap test.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/make-promises-safe.git"},"keywords":["promise","promises","safe","unhandled","rejection","unhandledRejection"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/make-promises-safe/issues"},"homepage":"https://github.com/mcollina/make-promises-safe#readme","devDependencies":{"pre-commit":"^1.2.2","snazzy":"^7.0.0","standard":"^10.0.2","tap":"^10.3.3"},"gitHead":"4209c75c042275ef8dba77254e62bc3ec263512c","_id":"make-promises-safe@4.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.12.0","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"cee2ccf0871753be6829828483f32de397cf7594","size":2603,"noattachment":false,"key":"/make-promises-safe/-/make-promises-safe-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-promises-safe/download/make-promises-safe-4.0.0.tgz"},"maintainers":[{"name":"matteo.collina","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-promises-safe_4.0.0_1542723957472_0.23993939996620428"},"_hasShrinkwrap":false,"publish_time":1542723957588,"_cnpm_publish_time":1542723957588},"3.0.0":{"name":"make-promises-safe","version":"3.0.0","description":"Crash or abort if you get an unhandledRejection or multipleResolves","main":"make-promises-safe.js","scripts":{"test":"standard | snazzy && tap test.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/make-promises-safe.git"},"keywords":["promise","promises","safe","unhandled","rejection","unhandledRejection"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/make-promises-safe/issues"},"homepage":"https://github.com/mcollina/make-promises-safe#readme","devDependencies":{"pre-commit":"^1.2.2","semver":"^5.6.0","snazzy":"^7.0.0","standard":"^10.0.2","tap":"^10.3.3"},"gitHead":"8d5c86df009c0d3db2cb6571423bd24bdcefff37","_id":"make-promises-safe@3.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.12.0","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"84cdf9e3e4f3144bb0f9f52d25569849063e7a90","size":3583,"noattachment":false,"key":"/make-promises-safe/-/make-promises-safe-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-promises-safe/download/make-promises-safe-3.0.0.tgz"},"maintainers":[{"name":"matteo.collina","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-promises-safe_3.0.0_1541064593372_0.6889143501626351"},"_hasShrinkwrap":false,"publish_time":1541064593515,"_cnpm_publish_time":1541064593515,"deprecated":"it unintentionally crashes the process on every Promise.race()"},"2.0.0":{"name":"make-promises-safe","version":"2.0.0","description":"Crash or abort if you get an unhandledRejection or multipleResolves","main":"make-promises-safe.js","scripts":{"test":"standard | snazzy && tap test.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/make-promises-safe.git"},"keywords":["promise","promises","safe","unhandled","rejection","unhandledRejection"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/make-promises-safe/issues"},"homepage":"https://github.com/mcollina/make-promises-safe#readme","devDependencies":{"pre-commit":"^1.2.2","snazzy":"^7.0.0","standard":"^10.0.2","tap":"^10.3.3"},"gitHead":"bf1c62dd3e9ecb47b07eff89517b07bf0e910097","_id":"make-promises-safe@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.12.0","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"50a24aa25cb6ef1d1915d3008947670e66ec04c8","size":2609,"noattachment":false,"key":"/make-promises-safe/-/make-promises-safe-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-promises-safe/download/make-promises-safe-2.0.0.tgz"},"maintainers":[{"name":"matteo.collina","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-promises-safe_2.0.0_1540489345453_0.8717122690076506"},"_hasShrinkwrap":false,"publish_time":1540489345626,"_cnpm_publish_time":1540489345626,"deprecated":"this release did not contain what it was planning to contain, use v3.0.0 instead for multipleResolves support"},"1.1.0":{"name":"make-promises-safe","version":"1.1.0","description":"Crash or abort if you get an unhandledRejection","main":"make-promises-safe.js","scripts":{"test":"standard | snazzy && tap test.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/make-promises-safe.git"},"keywords":["promise","promises","safe","unhandled","rejection","unhandledRejection"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/make-promises-safe/issues"},"homepage":"https://github.com/mcollina/make-promises-safe#readme","devDependencies":{"pre-commit":"^1.2.2","snazzy":"^7.0.0","standard":"^10.0.2","tap":"^10.3.3"},"gitHead":"c6c6604080674a2f5e9946b177d945e24c4a8e5a","_id":"make-promises-safe@1.1.0","_shasum":"b4d28c61ef8ad5502f38dbb3a0ee89627f76ad61","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.0","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"b4d28c61ef8ad5502f38dbb3a0ee89627f76ad61","size":3087,"noattachment":false,"key":"/make-promises-safe/-/make-promises-safe-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-promises-safe/download/make-promises-safe-1.1.0.tgz"},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-promises-safe-1.1.0.tgz_1498168633084_0.896346993977204"},"directories":{},"publish_time":1498168633971,"_hasShrinkwrap":false,"_cnpm_publish_time":1498168633971},"1.0.1":{"name":"make-promises-safe","version":"1.0.1","description":"Crash or abort if you get an unhandledRejection","main":"make-promises-safe.js","scripts":{"test":"standard | snazzy && tap test.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/make-promises-safe.git"},"keywords":["promise","promises","safe","unhandled","rejection","unhandledRejection"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/make-promises-safe/issues"},"homepage":"https://github.com/mcollina/make-promises-safe#readme","devDependencies":{"pre-commit":"^1.2.2","snazzy":"^7.0.0","standard":"^10.0.2","tap":"^10.3.3"},"gitHead":"ffdceee69dd4a666e10fc0b486c53ad796b01ab3","_id":"make-promises-safe@1.0.1","_npmVersion":"5.0.3","_nodeVersion":"6.10.1","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"19828995eb1f67cc25a9a7df25d082afc0ea17da","size":3020,"noattachment":false,"key":"/make-promises-safe/-/make-promises-safe-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-promises-safe/download/make-promises-safe-1.0.1.tgz"},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-promises-safe-1.0.1.tgz_1497890041613_0.566269418457523"},"directories":{},"publish_time":1497890042475,"_hasShrinkwrap":false,"_cnpm_publish_time":1497890042475},"1.0.0":{"name":"make-promises-safe","version":"1.0.0","description":"Crash or abort if you get an unhandledRejection","main":"make-promises-safe.js","scripts":{"test":"standard | snazzy && tap test.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/make-promises-safe.git"},"keywords":["promise","promises","safe","unhandled","rejection","unhandledRejection"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/make-promises-safe/issues"},"homepage":"https://github.com/mcollina/make-promises-safe#readme","devDependencies":{"pre-commit":"^1.2.2","snazzy":"^7.0.0","standard":"^10.0.2","tap":"^10.3.3"},"gitHead":"b0375ad06558821fa7207cffb2607bdcfcc86b54","_id":"make-promises-safe@1.0.0","_npmVersion":"5.0.3","_nodeVersion":"6.10.1","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"0043400fcca507b466c2651194920e955d0f96be","size":2967,"noattachment":false,"key":"/make-promises-safe/-/make-promises-safe-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-promises-safe/download/make-promises-safe-1.0.0.tgz"},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-promises-safe-1.0.0.tgz_1497889661136_0.0010998109355568886"},"directories":{},"publish_time":1497889662131,"_cnpm_publish_time":1497889662131,"_hasShrinkwrap":false}},"readme":"# make-promises-safe &nbsp;&nbsp;[![Build Status](https://travis-ci.org/mcollina/make-promises-safe.svg?branch=master)](https://travis-ci.org/mcollina/make-promises-safe)\n\nA node.js module to make the use of promises safe.\nIt implements the deprecation [DEP0018][unhandled] of Node.js in versions 6+.\nUsing Promises without this module might cause file descriptor and memory\nleaks.\n\n**It is important that this module is only used in top-level program code, not\nin reusable modules!**\n\n## The Problem\n\nNode.js crashes if there is an uncaught exception, while it does not\ncrash if there is an `'unhandledRejection'`, i.e. a Promise without a\n`.catch()` handler.\n\n**If you are using promises, you should attach a `.catch()` handler\nsynchronously**.\n\nAs an example, the following server will leak a file descriptor because\nof a missing `.catch()`  handler:\n\n```js\nconst http = require('http')\nconst server = http.createServer(handle)\n\nserver.listen(3000)\n\nfunction handle (req, res) {\n  doStuff()\n    .then((body) => {\n      res.end(body)\n    })\n}\n\nfunction doStuff () {\n  if (Math.random() < 0.5) {\n    return Promise.reject(new Error('kaboom'))\n  }\n\n  return Promise.resolve('hello world')\n}\n```\n\n## The Solution\n\n`make-promises-safe` installs an `process.on('unhandledRejection')`\nhandler that prints the stacktrace and exits the process with an exit\ncode of 1, just like any uncaught exception.\n\n## Install\n\n```\nnpm install make-promises-safe --save\n```\n\n## Usage\n\n```js\n'use strict'\n\nrequire('make-promises-safe') // installs an 'unhandledRejection' handler\nconst http = require('http')\nconst server = http.createServer(handle)\n\nserver.listen(3000)\n\nfunction handle (req, res) {\n  doStuff()\n    .then((body) => {\n      res.end(body)\n    })\n}\n\nfunction doStuff () {\n  if (Math.random() < 0.5) {\n    return Promise.reject(new Error('kaboom'))\n  }\n\n  return Promise.resolve('hello world')\n}\n```\n\n### as a preloader\n\nYou can add this behavior to any Node.js application by using it as a\npreloader:\n\n```\nnode -r make-promises-safe server.js\n```\n\n### with core dumps\n\nYou can also create a core dump when an unhandled rejection occurs:\n\n\n```\nrequire('make-promises-safe').abort = true\n```\n\n### With custom logging\n\nYou can add a custom logger to log errors in your own format. To do this override the `logError` property with a function that takes a single `Error` parameter. This defaults to `console.error`.\n\n```\nconst makePromisesSafe = require('make-promises-safe');\nmakePromisesSafe.logError = function(err) {\n  // log the err object\n}\n```\n\n## License\n\nMIT\n\n[unhandled]: https://nodejs.org/dist/latest-v8.x/docs/api/deprecations.html#deprecations_dep0018_unhandled_promise_rejections\n","_attachments":{},"homepage":"https://github.com/mcollina/make-promises-safe#readme","bugs":{"url":"https://github.com/mcollina/make-promises-safe/issues"},"license":"MIT"}