Skip to content

Commit

Permalink
fixup! fixup! src: add cli option to preserve env vars on dr
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Nov 7, 2024
1 parent d4460ea commit fed0381
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
11 changes: 5 additions & 6 deletions lib/internal/process/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const {
} = require('internal/validators');
const nr = internalBinding('report');

let excludeEnv;

const report = {
writeReport(file, err) {
if (typeof file === 'object' && file !== null) {
Expand Down Expand Up @@ -108,10 +106,11 @@ const report = {
nr.setReportOnUncaughtException(trigger);
},
get excludeEnv() {
if (excludeEnv === undefined) {
excludeEnv = nr.shouldExcludeEnvironmentVariables();
}
return excludeEnv;
return nr.getExcludeEnv();
},
set excludeEnv(b) {
validateBoolean(b, 'excludeEnv');
nr.setExcludeEnv(b);
},
};

Expand Down
26 changes: 15 additions & 11 deletions src/node_report_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ static void SetExcludeNetwork(const FunctionCallbackInfo<Value>& info) {
env->options()->report_exclude_network = info[0]->IsTrue();
}

static void GetExcludeEnv(const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
info.GetReturnValue().Set(env->report_exclude_env());
}

static void SetExcludeEnv(const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
CHECK(info[0]->IsBoolean());
env->options()->report_exclude_env = info[0]->IsTrue();
}

static void GetDirectory(const FunctionCallbackInfo<Value>& info) {
Mutex::ScopedLock lock(per_process::cli_options_mutex);
Environment* env = Environment::GetCurrent(info);
Expand Down Expand Up @@ -170,12 +181,6 @@ static void ShouldReportOnUncaughtException(
env->isolate_data()->options()->report_uncaught_exception);
}

static void ShouldExcludeEnvironmentVariables(
const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
info.GetReturnValue().Set(env->report_exclude_env());
}

static void SetReportOnUncaughtException(
const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
Expand All @@ -193,6 +198,8 @@ static void Initialize(Local<Object> exports,
SetMethod(context, exports, "setCompact", SetCompact);
SetMethod(context, exports, "getExcludeNetwork", GetExcludeNetwork);
SetMethod(context, exports, "setExcludeNetwork", SetExcludeNetwork);
SetMethod(context, exports, "getExcludeEnv", GetExcludeEnv);
SetMethod(context, exports, "setExcludeEnv", SetExcludeEnv);
SetMethod(context, exports, "getDirectory", GetDirectory);
SetMethod(context, exports, "setDirectory", SetDirectory);
SetMethod(context, exports, "getFilename", GetFilename);
Expand All @@ -208,10 +215,6 @@ static void Initialize(Local<Object> exports,
exports,
"shouldReportOnUncaughtException",
ShouldReportOnUncaughtException);
SetMethod(context,
exports,
"shouldExcludeEnvironmentVariables",
ShouldExcludeEnvironmentVariables);
SetMethod(context,
exports,
"setReportOnUncaughtException",
Expand All @@ -225,6 +228,8 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(SetCompact);
registry->Register(GetExcludeNetwork);
registry->Register(SetExcludeNetwork);
registry->Register(GetExcludeEnv);
registry->Register(SetExcludeEnv);
registry->Register(GetDirectory);
registry->Register(SetDirectory);
registry->Register(GetFilename);
Expand All @@ -236,7 +241,6 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(ShouldReportOnSignal);
registry->Register(SetReportOnSignal);
registry->Register(ShouldReportOnUncaughtException);
registry->Register(ShouldExcludeEnvironmentVariables);
registry->Register(SetReportOnUncaughtException);
}

Expand Down

0 comments on commit fed0381

Please sign in to comment.