node
node copied to clipboard
src: fixup Error.stackTraceLimit during snapshot building
src: parse --stack-trace-limit and use it in --trace-* flags
Previously, --trace-exit and --trace-sync-io doesn't take care of --stack-trace-limit and always print a stack trace with maximum size of 10. This patch parses --stack-trace-limit during initialization and use the value in --trace-* flags.
src: fixup Error.stackTraceLimit during snapshot building
When V8 creates a context for snapshot building, it does not install Error.stackTraceLimit. As a result, error.stack would be undefined in the snapshot builder script unless users explicitly initialize Error.stackTraceLimit, which may be surprising.
This patch initializes Error.stackTraceLimit based on the value of --stack-trace-limit to prevent the surprise. If users have modified Error.stackTraceLimit in the builder script, the modified value would be restored during deserialization. Otherwise, the fixed up limit would be deleted since V8 expects to find it unset and re-initialize it during snapshot deserialization.
Fixes: https://github.com/nodejs/node/issues/55100
Review requested:
- [ ] @nodejs/startup
CI: https://ci.nodejs.org/job/node-test-pull-request/62767/
Codecov Report
Attention: Patch coverage is 87.17949% with 10 lines in your changes missing coverage. Please review.
Project coverage is 88.24%. Comparing base (
b64006c) to head (ceeee4d). Report is 406 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #55121 +/- ##
=======================================
Coverage 88.24% 88.24%
=======================================
Files 652 651 -1
Lines 183912 183960 +48
Branches 35862 35866 +4
=======================================
+ Hits 162296 162342 +46
+ Misses 14905 14901 -4
- Partials 6711 6717 +6
| Files with missing lines | Coverage Ξ | |
|---|---|---|
| lib/internal/v8/startup_snapshot.js | 99.23% <100.00%> (+0.06%) |
:arrow_up: |
| src/env-inl.h | 96.56% <100.00%> (+0.01%) |
:arrow_up: |
| src/env.cc | 85.57% <100.00%> (+0.02%) |
:arrow_up: |
| src/env.h | 97.95% <ΓΈ> (-0.05%) |
:arrow_down: |
| src/node_options.h | 98.22% <100.00%> (+0.01%) |
:arrow_up: |
| src/node_options-inl.h | 80.80% <50.00%> (-0.28%) |
:arrow_down: |
| src/node_options.cc | 87.39% <50.00%> (-0.66%) |
:arrow_down: |
| lib/internal/main/mksnapshot.js | 95.90% <87.75%> (-1.39%) |
:arrow_down: |
do we want to cover the case where Error.stackTraceLimit is modified in a user serialize callback?
hmm I think this PR already does it, but yeah it's missing a test. Will add one
Yes, I meant a test coverage.
CI: https://ci.nodejs.org/job/node-test-pull-request/62790/
CI: https://ci.nodejs.org/job/node-test-pull-request/62799/
CI: https://ci.nodejs.org/job/node-test-pull-request/62804/
CI: https://ci.nodejs.org/job/node-test-pull-request/62806/
CI: https://ci.nodejs.org/job/node-test-pull-request/62845/
CI: https://ci.nodejs.org/job/node-test-pull-request/62853/
Landed in 371ed85e4e1d02c63227d17f226e5301f4a8ef61...33bbf3751b9f6a516f605cb7088adb786a3f8cfb