Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cc3e427

Browse filesBrowse files
legendecastargos
authored andcommitted
src: prevent hard coding stack trace limit
Refer to Environment::stack_trace_limit() while printing fresh stacktraces in c++ land. PR-URL: #30752 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent e5c68cd commit cc3e427
Copy full SHA for cc3e427

File tree

Expand file treeCollapse file tree

6 files changed

+12
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+12
-7
lines changed
Open diff view settings
Collapse file

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,9 @@ void Environment::PrintSyncTrace() const {
588588

589589
fprintf(
590590
stderr, "(node:%d) WARNING: Detected use of sync API\n", uv_os_getpid());
591-
PrintStackTrace(
592-
isolate(),
593-
StackTrace::CurrentStackTrace(isolate(), 10, StackTrace::kDetailed));
591+
PrintStackTrace(isolate(),
592+
StackTrace::CurrentStackTrace(
593+
isolate(), stack_trace_limit(), StackTrace::kDetailed));
594594
}
595595

596596
void Environment::RunCleanup() {
@@ -943,9 +943,9 @@ void Environment::Exit(int exit_code) {
943943

944944
fprintf(
945945
stderr, "WARNING: Exited the environment with code %d\n", exit_code);
946-
PrintStackTrace(
947-
isolate(),
948-
StackTrace::CurrentStackTrace(isolate(), 10, StackTrace::kDetailed));
946+
PrintStackTrace(isolate(),
947+
StackTrace::CurrentStackTrace(
948+
isolate(), stack_trace_limit(), StackTrace::kDetailed));
949949
}
950950
if (is_main_thread()) {
951951
stop_sub_worker_contexts();
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,8 @@ class Environment : public MemoryRetainer {
12301230

12311231
inline AsyncRequest* thread_stopper() { return &thread_stopper_; }
12321232

1233+
inline int32_t stack_trace_limit() const { return 10; }
1234+
12331235
#if HAVE_INSPECTOR
12341236
void set_coverage_connection(
12351237
std::unique_ptr<profiler::V8CoverageConnection> connection);
Collapse file

‎src/node_errors.cc‎

Copy file name to clipboardExpand all lines: src/node_errors.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static std::string GetErrorSource(Isolate* isolate,
145145
}
146146

147147
void PrintStackTrace(Isolate* isolate, Local<StackTrace> stack) {
148-
for (int i = 0; i < stack->GetFrameCount() - 1; i++) {
148+
for (int i = 0; i < stack->GetFrameCount(); i++) {
149149
Local<StackFrame> stack_frame = stack->GetFrame(isolate, i);
150150
node::Utf8Value fn_name_s(isolate, stack_frame->GetFunctionName());
151151
node::Utf8Value script_name(isolate, stack_frame->GetScriptName());
Collapse file

‎test/message/throw_error_with_getter_throw_traced.out‎

Copy file name to clipboardExpand all lines: test/message/throw_error_with_getter_throw_traced.out
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ Thrown at:
1010
at Module.load (internal/modules/cjs/loader.js:*:*)
1111
at Module._load (internal/modules/cjs/loader.js:*:*)
1212
at executeUserEntryPoint (internal/modules/run_main.js:*:*)
13+
at internal/main/run_main_module.js:*:*
Collapse file

‎test/message/throw_null_traced.out‎

Copy file name to clipboardExpand all lines: test/message/throw_null_traced.out
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ Thrown at:
1010
at Module.load (internal/modules/cjs/loader.js:*:*)
1111
at Module._load (internal/modules/cjs/loader.js:*:*)
1212
at executeUserEntryPoint (internal/modules/run_main.js:*:*)
13+
at internal/main/run_main_module.js:*:*
Collapse file

‎test/message/throw_undefined_traced.out‎

Copy file name to clipboardExpand all lines: test/message/throw_undefined_traced.out
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ Thrown at:
1010
at Module.load (internal/modules/cjs/loader.js:*:*)
1111
at Module._load (internal/modules/cjs/loader.js:*:*)
1212
at executeUserEntryPoint (internal/modules/run_main.js:*:*)
13+
at internal/main/run_main_module.js:*:*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.