%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
'use strict'; const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); const id_obj = {}; let collect = true; const hook = async_hooks.createHook({ before(id) { if (collect) id_obj[id] = true; }, after(id) { delete id_obj[id]; }, }).enable(); process.once('uncaughtException', common.mustCall((er) => { assert.strictEqual(er.message, 'bye'); collect = false; })); setImmediate(common.mustCall(() => { process.nextTick(common.mustCall(() => { assert.strictEqual(Object.keys(id_obj).length, 0); hook.disable(); })); // Create a stack of async ids that will need to be emitted in the case of // an uncaught exception. const ar1 = new async_hooks.AsyncResource('Mine'); ar1.runInAsyncScope(() => { const ar2 = new async_hooks.AsyncResource('Mine'); ar2.runInAsyncScope(() => { throw new Error('bye'); }); }); // TODO(trevnorris): This test shows that the after() hooks are always called // correctly, but it doesn't solve where the emitDestroy() is missed because // of the uncaught exception. Simple solution is to always call emitDestroy() // before the emitAfter(), but how to codify this? }));