test-callback-errors-are-not-caught.js 398 B

123456789101112131415161718192021
  1. var common = require('../../common');
  2. var connection = common.createConnection();
  3. var assert = require('assert');
  4. var err = new Error('uncaught exception');
  5. connection.connect(function() {
  6. throw err;
  7. });
  8. var caughtErr;
  9. process.on('uncaughtException', function(err) {
  10. caughtErr = err;
  11. process.exit(0);
  12. });
  13. process.on('exit', function() {
  14. assert.strictEqual(caughtErr, err);
  15. });