Skip to content

Instantly share code, notes, and snippets.

@naholyr
Created February 20, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naholyr/7541bdd12817578eee74 to your computer and use it in GitHub Desktop.
Save naholyr/7541bdd12817578eee74 to your computer and use it in GitHub Desktop.
// foo() fait une opération compliquée
// mais c'est codé un peu avec les pieds et un des EventEmitter déclaré (et non exposé)
// dans la fonction émet parfois un "error" non catché qui pète mon application :(
var foo = require("./module-pourri");
// Ça fait parfois péter mon app :(
//foo();
// Magie, j'ai juste à l'isoler dans un domaine :D
var d = require("domain").create();
d.on("error", console.error);
var bar = d.bind(foo);
bar();
"use strict";
module.exports = function foo () {
(new (require("events").EventEmitter)).emit("error", new Error("catch me if you can"));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment