| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0642a14 commit c06e2b0
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ | |||
| 9 | 9 | #include "v8-profiler.h" | |
| 10 | 10 | ||
| 11 | 11 | using v8::Array; | |
| 12 | + using v8::Boolean; | ||
| 12 | 13 | using v8::Context; | |
| 13 | 14 | using v8::Function; | |
| 14 | 15 | using v8::FunctionCallbackInfo; | |
@@ -231,7 +232,9 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb, | |||
| 231 | 232 | Local<Value> ret = cb->Call(context, argc, argv); | |
| 232 | 233 | ||
| 233 | 234 | if (ran_init_callback() && !post_fn.IsEmpty()) { | |
| 234 | - if (post_fn->Call(context, 1, &uid).IsEmpty()) | ||
| 235 | + Local<Value> did_throw = Boolean::New(env()->isolate(), ret.IsEmpty()); | ||
| 236 | + Local<Value> vals[] = { uid, did_throw }; | ||
| 237 | + if (post_fn->Call(context, arraysize(vals), vals).IsEmpty()) | ||
| 235 | 238 | FatalError("node::AsyncWrap::MakeCallback", "post hook threw"); | |
| 236 | 239 | } | |
| 237 | 240 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1172,7 +1172,12 @@ Local<Value> MakeCallback(Environment* env, | |||
| 1172 | 1172 | Local<Value> ret = callback->Call(recv, argc, argv); | |
| 1173 | 1173 | ||
| 1174 | 1174 | if (ran_init_callback && !post_fn.IsEmpty()) { | |
| 1175 | - if (post_fn->Call(object, 0, nullptr).IsEmpty()) | ||
| 1175 | + Local<Value> did_throw = Boolean::New(env->isolate(), ret.IsEmpty()); | ||
| 1176 | + // Currently there's no way to retrieve an uid from node::MakeCallback(). | ||
| 1177 | + // This needs to be fixed. | ||
| 1178 | + Local<Value> vals[] = | ||
| 1179 | + { Undefined(env->isolate()).As<Value>(), did_throw }; | ||
| 1180 | + if (post_fn->Call(object, arraysize(vals), vals).IsEmpty()) | ||
| 1176 | 1181 | FatalError("node::MakeCallback", "post hook threw"); | |
| 1177 | 1182 | } | |
| 1178 | 1183 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,34 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const async_wrap = process.binding('async_wrap'); | ||
| 6 | + var asyncThrows = 0; | ||
| 7 | + var uncaughtExceptionCount = 0; | ||
| 8 | + | ||
| 9 | + process.on('uncaughtException', (e) => { | ||
| 10 | + assert.equal(e.message, 'oh noes!', 'error messages do not match'); | ||
| 11 | + }); | ||
| 12 | + | ||
| 13 | + process.on('exit', () => { | ||
| 14 | + process.removeAllListeners('uncaughtException'); | ||
| 15 | + assert.equal(uncaughtExceptionCount, 1); | ||
| 16 | + assert.equal(uncaughtExceptionCount, asyncThrows); | ||
| 17 | + }); | ||
| 18 | + | ||
| 19 | + function init() { } | ||
| 20 | + function post(id, threw) { | ||
| 21 | + if (threw) | ||
| 22 | + uncaughtExceptionCount++; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + async_wrap.setupHooks({ init, post }); | ||
| 26 | + async_wrap.enable(); | ||
| 27 | + | ||
| 28 | + // Timers still aren't supported, so use crypto API. | ||
| 29 | + // It's also important that the callback not happen in a nextTick, like many | ||
| 30 | + // error events in core. | ||
| 31 | + require('crypto').randomBytes(0, () => { | ||
| 32 | + asyncThrows++; | ||
| 33 | + throw new Error('oh noes!'); | ||
| 34 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments