diff --git a/test/fixtures/debug-uncaught-async.js b/test/fixtures/debug-uncaught-async.js new file mode 100644 index 00000000000000..88881b9a90898d --- /dev/null +++ b/test/fixtures/debug-uncaught-async.js @@ -0,0 +1,16 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const debug = require('_debugger'); + +function emit() { + const error = new Error('fhqwhgads'); + process.emit('uncaughtException', error); +} + +assert.doesNotThrow(emit); + +debug.start(['sterrance']); + +setImmediate(emit); diff --git a/test/parallel/test-debug-uncaught-exception-async.js b/test/parallel/test-debug-uncaught-exception-async.js new file mode 100644 index 00000000000000..29947cfd92fbb9 --- /dev/null +++ b/test/parallel/test-debug-uncaught-exception-async.js @@ -0,0 +1,22 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const spawn = require('child_process').spawn; + +const emitUncaught = path.join(common.fixturesDir, 'debug-uncaught-async.js'); +const result = spawn(process.execPath, [emitUncaught], {encoding: 'utf8'}); + +var stderr = ''; +result.stderr.on('data', (data) => { + stderr += data; +}); + +result.on('close', (code) => { + const expectedMessage = + "There was an internal error in Node's debugger. Please report this bug."; + + assert.strictEqual(code, 1); + assert(stderr.includes(expectedMessage)); + assert(stderr.includes('Error: fhqwhgads')); +});