mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
cli: add --stack-trace-limit to NODE_OPTIONS
I decided that it would make a lot of sense for me to set `NODE_OPTIONS=--stack-trace-limit=100` on my development machine. This code allows me to do that. :) PR-URL: https://github.com/nodejs/node/pull/16495 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ryan Graham <r.m.graham@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
This commit is contained in:
1 parent
949ace9524
commit
ec7996ca15
3 files changed
+17
-5
No files matched your search
@@ -485,6 +485,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
|
||||
|
||||
@@ -4004,6 +4004,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++) {
|
||||
|
||||
@@ -34,16 +34,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>`);
|
||||
|
||||
Reference in new issue
Block a user