Skip to content

Commit 89f2d46

Browse files
committed
src: add get/set pair for env context awareness
PR-URL: #35024 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 8bdbacf commit 89f2d46

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/env-inl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,14 @@ inline bool Environment::abort_on_uncaught_exception() const {
513513
return options_->abort_on_uncaught_exception;
514514
}
515515

516+
inline void Environment::set_force_context_aware(bool value) {
517+
options_->force_context_aware = value;
518+
}
519+
520+
inline bool Environment::force_context_aware() const {
521+
return options_->force_context_aware;
522+
}
523+
516524
inline void Environment::set_abort_on_uncaught_exception(bool value) {
517525
options_->abort_on_uncaught_exception = value;
518526
}

src/env.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,9 @@ class Environment : public MemoryRetainer {
10681068
void PrintSyncTrace() const;
10691069
inline void set_trace_sync_io(bool value);
10701070

1071+
inline void set_force_context_aware(bool value);
1072+
inline bool force_context_aware() const;
1073+
10711074
// This stores whether the --abort-on-uncaught-exception flag was passed
10721075
// to Node.
10731076
inline bool abort_on_uncaught_exception() const;

src/node_binding.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
470470

471471
if (mp != nullptr) {
472472
if (mp->nm_context_register_func == nullptr) {
473-
if (env->options()->force_context_aware) {
473+
if (env->force_context_aware()) {
474474
dlib->Close();
475475
THROW_ERR_NON_CONTEXT_AWARE_DISABLED(env);
476476
return false;

0 commit comments

Comments
 (0)