message: Fix double-hooking in require instrumentation
diff: @@ -30,12 +30,14 @@ function instrument(Raven, config) {
  }
  Raven.instrumentedOriginals = [];
  + Raven.instrumentedModules = [];
  var Module = require('module');
  - fill(Module.prototype, 'require', function (origRequire) {
  - return function (moduleId) {
  - var origModule = origRequire.call(this, moduleId);
  - if (config[moduleId]) {
  + fill(Module, '_load', function (origLoad) {
  + return function (moduleId, parent, isMain) {
  + var origModule = origLoad.apply(this, arguments);
  + if (config[moduleId] && Raven.instrumentedModules.indexOf(moduleId) === -1) {
  + Raven.instrumentedModules.push(moduleId);
  return require('./' + moduleId)(Raven, origModule, Raven.instrumentedOriginals);
  }
  return origModule;
  @@ -47,8 +49,11 @@ function instrument(Raven, config) {
  require('console');
  }
  - // special case: loading http proactively ensures that if https loads it, it's been instrumented
  - // todo: might be able to avoid need for this, still investigating
  + // observation: when the https module does its own require('http'), it *does not* hit our hooked require to instrument http on the fly
  + // but if we've previously instrumented http, https *does* get our already-instrumented version
  + // this is because raven's transports are required before this instrumentation takes place, which loads https (and http)
  + // so module cache will have uninstrumented http; proactively loading it here ensures instrumented version is in module cache
  + // alternatively we could refactor to load our transports later, but this is easier and doesn't have much drawback
  if (config.http) {
  require('http');
  }
  