| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8681c83 commit 700f766
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,8 @@ const { | |||
| 20 | 20 | clearAsyncIdStack, | |
| 21 | 21 | hasAsyncIdStack, | |
| 22 | 22 | afterHooksExist, | |
| 23 | - emitAfter | ||
| 23 | + emitAfter, | ||
| 24 | + popAsyncContext, | ||
| 24 | 25 | } = require('internal/async_hooks'); | |
| 25 | 26 | ||
| 26 | 27 | // shouldAbortOnUncaughtToggle is a typed array for faster | |
@@ -183,7 +184,11 @@ function createOnGlobalUncaughtException() { | |||
| 183 | 184 | // Emit the after() hooks now that the exception has been handled. | |
| 184 | 185 | if (afterHooksExist()) { | |
| 185 | 186 | do { | |
| 186 | - emitAfter(executionAsyncId()); | ||
| 187 | + const asyncId = executionAsyncId(); | ||
| 188 | + if (asyncId === 0) | ||
| 189 | + popAsyncContext(0); | ||
| 190 | + else | ||
| 191 | + emitAfter(asyncId); | ||
| 187 | 192 | } while (hasAsyncIdStack()); | |
| 188 | 193 | } | |
| 189 | 194 | // And completely empty the id stack, including anything that may be | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -168,9 +168,6 @@ class ActivityCollector { | |||
| 168 | 168 | } | |
| 169 | 169 | const err = new Error(`Found a handle whose ${hook}` + | |
| 170 | 170 | ' hook was invoked but not its init hook'); | |
| 171 | - // Don't throw if we see invocations due to an assertion in a test | ||
| 172 | - // failing since we want to list the assertion failure instead | ||
| 173 | - if (/process\._fatalException/.test(err.stack)) return null; | ||
| 174 | 171 | throw err; | |
| 175 | 172 | } | |
| 176 | 173 | return h; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const initHooks = require('./init-hooks'); | ||
| 5 | + | ||
| 6 | + const hooks = initHooks(); | ||
| 7 | + hooks.enable(); | ||
| 8 | + | ||
| 9 | + setImmediate(() => { | ||
| 10 | + throw new Error(); | ||
| 11 | + }); | ||
| 12 | + | ||
| 13 | + setTimeout(() => { | ||
| 14 | + throw new Error(); | ||
| 15 | + }, 1); | ||
| 16 | + | ||
| 17 | + process.on('uncaughtException', common.mustCall(2)); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments