mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
958 B
39 lines
958 B
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
|
|
const assert = require('assert');
|
|
const async_wrap = process.binding('async_wrap');
|
|
var asyncThrows = 0;
|
|
var uncaughtExceptionCount = 0;
|
|
|
|
process.on('uncaughtException', (e) => {
|
|
assert.equal(e.message, 'oh noes!', 'error messages do not match');
|
|
});
|
|
|
|
process.on('exit', () => {
|
|
process.removeAllListeners('uncaughtException');
|
|
assert.equal(uncaughtExceptionCount, 1);
|
|
assert.equal(uncaughtExceptionCount, asyncThrows);
|
|
});
|
|
|
|
function init() { }
|
|
function post(id, threw) {
|
|
if (threw)
|
|
uncaughtExceptionCount++;
|
|
}
|
|
|
|
async_wrap.setupHooks({ init, post });
|
|
async_wrap.enable();
|
|
|
|
// Timers still aren't supported, so use crypto API.
|
|
// It's also important that the callback not happen in a nextTick, like many
|
|
// error events in core.
|
|
require('crypto').randomBytes(0, () => {
|
|
asyncThrows++;
|
|
throw new Error('oh noes!');
|
|
});
|
|
|