Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: add --stack-trace-limit to NODE_OPTIONS #16495

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
@@ -471,6 +471,7 @@ Node options that are allowed are:
V8 options that are allowed are:
- `--abort-on-uncaught-exception`
- `--max-old-space-size`
- `--stack-trace-limit`

### `NODE_PENDING_DEPRECATION=1`
<!-- YAML
1 change: 1 addition & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
@@ -4043,6 +4043,7 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env,
// V8 options (define with '_', which allows '-' or '_')
"--abort_on_uncaught_exception",
"--max_old_space_size",
"--stack_trace_limit",
};

for (unsigned i = 0; i < arraysize(whitelist); i++) {
20 changes: 15 additions & 5 deletions test/parallel/test-cli-node-options.js
Original file line number Diff line number Diff line change
@@ -33,16 +33,26 @@ if (common.hasCrypto) {
// V8 options
expect('--abort_on-uncaught_exception', 'B\n');
expect('--max-old-space-size=0', 'B\n');
expect('--stack-trace-limit=100',
/(\s*at f \(\[eval\]:1:\d*\)\n){100}/,
'(function f() { f(); })();',
true);

function expect(opt, want) {
const argv = ['-e', 'console.log("B")'];
function expect(opt, want, command = 'console.log("B")', wantsError = false) {
const argv = ['-e', command];
const opts = {
env: Object.assign({}, process.env, { NODE_OPTIONS: opt }),
maxBuffer: 1e6,
};
exec(process.execPath, argv, opts, common.mustCall((err, stdout) => {
assert.ifError(err);
if (stdout.includes(want)) return;
if (typeof want === 'string')
want = new RegExp(want);
exec(process.execPath, argv, opts, common.mustCall((err, stdout, stderr) => {
if (wantsError) {
stdout = stderr;
} else {
assert.ifError(err);
}
if (want.test(stdout)) return;

const o = JSON.stringify(opt);
assert.fail(`For ${o}, failed to find ${want} in: <\n${stdout}\n>`);