Skip to content

Commit 3d623d8

Browse files
mhdawsoncodebytere
authored andcommitted
n-api: improve consistency of how we get context
Refs: nodejs/node-addon-api#764 Improve the consistency of how we get a context when needed. We generally used env->context() in N-API but there were are few exceptions that this PR addresses. Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: #36068 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent f9bbd35 commit 3d623d8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/js_native_api_v8.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ inline static napi_status ConcludeDeferred(napi_env env,
169169
NAPI_PREAMBLE(env);
170170
CHECK_ARG(env, result);
171171

172-
v8::Local<v8::Context> context = env->isolate->GetCurrentContext();
172+
v8::Local<v8::Context> context = env->context();
173173
v8impl::Persistent<v8::Value>* deferred_ref =
174174
NodePersistentFromJsDeferred(deferred);
175175
v8::Local<v8::Value> v8_deferred =
@@ -385,8 +385,7 @@ inline static napi_status Unwrap(napi_env env,
385385
CHECK_ARG(env, result);
386386
}
387387

388-
v8::Isolate* isolate = env->isolate;
389-
v8::Local<v8::Context> context = isolate->GetCurrentContext();
388+
v8::Local<v8::Context> context = env->context();
390389

391390
v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(js_object);
392391
RETURN_STATUS_IF_FALSE(env, value->IsObject(), napi_invalid_arg);

0 commit comments

Comments
 (0)