aboutsummaryrefslogtreecommitdiff
path: root/src/async-wrap-inl.h
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2014-09-02 11:30:45 -0700
committerTrevor Norris <trev.norris@gmail.com>2014-09-02 11:30:45 -0700
commit81a9739108bd3959b4b1331d3a2833a18bc2b2b4 (patch)
tree8dc10da5dfd3936922fafec0c295091270712e2a /src/async-wrap-inl.h
parentcdc01faed2b92f43a58cb86ff3300af1322cfaf6 (diff)
downloadandroid-node-v8-81a9739108bd3959b4b1331d3a2833a18bc2b2b4.tar.gz
android-node-v8-81a9739108bd3959b4b1331d3a2833a18bc2b2b4.tar.bz2
android-node-v8-81a9739108bd3959b4b1331d3a2833a18bc2b2b4.zip
node,async-wrap: verify domain enter/exit are set
The REPL global object lazy loads modules by placing getters for each. This causes MakeDomainCallback() to be run if a native module is loaded from the REPL, but if the domain module hasn't been loaded then there are no enter/exit callbacks to be called. Causing an assert() to fail. Fix the issue by conditionally running the callback instead of asserting it is available. Also add "addon" test to verify the fix. Fixes: #8231 Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/async-wrap-inl.h')
-rw-r--r--src/async-wrap-inl.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h
index 388ee19c2b..324c57b9ae 100644
--- a/src/async-wrap-inl.h
+++ b/src/async-wrap-inl.h
@@ -101,11 +101,11 @@ inline v8::Handle<v8::Value> AsyncWrap::MakeDomainCallback(
v8::Local<v8::Function> enter =
domain->Get(env()->enter_string()).As<v8::Function>();
- assert(enter->IsFunction());
- enter->Call(domain, 0, NULL);
-
- if (try_catch.HasCaught())
- return Undefined(env()->isolate());
+ if (enter->IsFunction()) {
+ enter->Call(domain, 0, NULL);
+ if (try_catch.HasCaught())
+ return Undefined(env()->isolate());
+ }
}
v8::Local<v8::Value> ret = cb->Call(context, argc, argv);
@@ -117,11 +117,11 @@ inline v8::Handle<v8::Value> AsyncWrap::MakeDomainCallback(
if (has_domain) {
v8::Local<v8::Function> exit =
domain->Get(env()->exit_string()).As<v8::Function>();
- assert(exit->IsFunction());
- exit->Call(domain, 0, NULL);
-
- if (try_catch.HasCaught())
- return Undefined(env()->isolate());
+ if (exit->IsFunction()) {
+ exit->Call(domain, 0, NULL);
+ if (try_catch.HasCaught())
+ return Undefined(env()->isolate());
+ }
}
if (has_async_listener()) {