Skip to content

Commit 169406b

Browse files
addaleaxtargos
authored andcommitted
src: add missing context scopes
Add scopes that ensure that the context associated with the current Environment is always entered when working with it. PR-URL: #36413 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 023291b commit 169406b

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/env.cc

+2
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ void Environment::InitializeLibuv() {
547547
[](uv_async_t* async) {
548548
Environment* env = ContainerOf(
549549
&Environment::task_queues_async_, async);
550+
HandleScope handle_scope(env->isolate());
551+
Context::Scope context_scope(env->context());
550552
env->RunAndClearNativeImmediates();
551553
});
552554
uv_unref(reinterpret_cast<uv_handle_t*>(&task_queues_async_));

src/node_file.cc

+2
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ inline void FileHandle::Close() {
288288
void FileHandle::CloseReq::Resolve() {
289289
Isolate* isolate = env()->isolate();
290290
HandleScope scope(isolate);
291+
Context::Scope context_scope(env()->context());
291292
InternalCallbackScope callback_scope(this);
292293
Local<Promise> promise = promise_.Get(isolate);
293294
Local<Promise::Resolver> resolver = promise.As<Promise::Resolver>();
@@ -297,6 +298,7 @@ void FileHandle::CloseReq::Resolve() {
297298
void FileHandle::CloseReq::Reject(Local<Value> reason) {
298299
Isolate* isolate = env()->isolate();
299300
HandleScope scope(isolate);
301+
Context::Scope context_scope(env()->context());
300302
InternalCallbackScope callback_scope(this);
301303
Local<Promise> promise = promise_.Get(isolate);
302304
Local<Promise::Resolver> resolver = promise.As<Promise::Resolver>();

0 commit comments

Comments
 (0)