Open szmarczak opened 3 years ago
Something like
const { EventEmitter, errorMonitor } = require('events'); EventEmitter.realInit = EventEmitter.init; EventEmitter.init = function(opts) { Error.captureStackTrace(this); this.on(errorMonitor, error => { error.creationStack = this.stack; }); return EventEmitter.realInit.call(this, opts); }; // Demo time! const https = require('https'); const request = https.request('https://example.com'); request.destroy();
Should we really recommend monkey-patching EventEmitter? I would much prefer if we would open an issue on Node.js with a proposal for a public API to make this easy.
EventEmitter
Agreed, I'll open an issue tomorrow
https://github.com/nodejs/node/issues/39917
Something like