title: Why is my Node.js getting "program terminated" without an error
body: <p>I have a fairly large Node.js project that's been working great for an extensive period of development. Recently however -- and unfortunately cannot pinpoint exactly when it changed -- my application has started exiting with <code>program terminated</code> <strong>only when running from within the node.js debugger</strong>.</p>
  
  <p><strong>The big question: How do I find out what is causing this error?</strong></p>
  
  <p><strong>Breakdown of what I know</strong>:</p>
  
  <ul>
  <li>Only seems to occur from within the debugger (e.g. <code>node debug main.js</code>)</li>
  <li>Same results with Node 4.2.5 &amp; 4.2.6. With Node 5.5.0, the debugger generally just stops working when this happens.</li>
  <li>There is <strong>no additional output</strong> such as stack trace or error messages, only "program terminated"</li>
  <li>process events of <code>SIGINT</code>, <code>exit</code>, nor <code>uncaughtException</code> are hit</li>
  <li>Through <code>console.log()</code> I've been able to determine that this happens when I <code>require</code> a module (more information on this below)</li>
  <li>The <code>require</code> logic is surrounded by <code>try</code>/<code>catch</code> but it does not catch</li>
  <li>I have tried using a <code>domain</code>'s <code>error</code> handler to catch this by putting the <code>require</code> portion in the <code>run</code> method but nothing caught there, either</li>
  <li>I've used tools such as <a href="https://github.com/pahen/madge" rel="noreferrer">madge</a> to ensure I do not have any circular dependencies (Perhaps there is a better way to do this)</li>
  </ul>
  
  <p><strong>About require</strong>:</p>
  
  <p>My program has a "plugin" type system in which modules are <code>require</code>'d at runtime as needed. The offending <code>require</code> is not deterministic from what I can tell, however: A module that can be <code>require</code>'d a few times in a row with success fails other times.</p>
  
  <p>Again, this is code that has been working for months. I've been making some fairly extensive changes (but not to the area of code using <code>require</code> mentioned above) when I started noticing this. Since I can often run for a few minutes without issue though many different code paths before seeing this, it's hard to say what is triggering this.</p>
  
  <p>What else can I do here?!</p>
  
  <p>For reference, the (not quite up to date as I've not pushed my changes) code <a href="http://github.com/NuSkooler/enigma-bbs/" rel="noreferrer">is on Github</a>, if that helps.</p>