diff options
author | Christopher Hiller <boneskull@boneskull.com> | 2019-07-10 13:27:44 -0700 |
---|---|---|
committer | Christopher Hiller <boneskull@boneskull.com> | 2019-07-12 14:48:09 -0700 |
commit | bff7a46f31f1da259071a1f4bd51aca726d5926e (patch) | |
tree | 16b62a84d9cc3ad1b5893bbb1d7039df066557ea /lib/internal/process/report.js | |
parent | 28e18cfff0d491e14889935a64395cbbb5b666a6 (diff) | |
download | android-node-v8-bff7a46f31f1da259071a1f4bd51aca726d5926e.tar.gz android-node-v8-bff7a46f31f1da259071a1f4bd51aca726d5926e.tar.bz2 android-node-v8-bff7a46f31f1da259071a1f4bd51aca726d5926e.zip |
report: modify getReport() to return an Object
It's likely that anyone using `process.report.getReport()` will be
processing the return value thereafter (e.g., filtering fields or
redacting secrets). This change eliminates boilerplate by calling
`JSON.parse()` on the return value.
Also modified the `validateContent()` and `validate()` test helpers in
`test/common/report.js` to be somewhat more obvious and helpful. Of
note, a report failing validation will now be easier (though still not
_easy_) to read when prepended to the stack trace.
- Refs: https://github.com/nodejs/diagnostics/issues/315
PR-URL: https://github.com/nodejs/node/pull/28630
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/internal/process/report.js')
-rw-r--r-- | lib/internal/process/report.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/internal/process/report.js b/lib/internal/process/report.js index 251c32a109..cc78aebbda 100644 --- a/lib/internal/process/report.js +++ b/lib/internal/process/report.js @@ -5,6 +5,7 @@ const { } = require('internal/errors').codes; const { validateSignalName, validateString } = require('internal/validators'); const nr = internalBinding('report'); +const { JSON } = primordials; const report = { writeReport(file, err) { if (typeof file === 'object' && file !== null) { @@ -26,7 +27,7 @@ const report = { else if (err === null || typeof err !== 'object') throw new ERR_INVALID_ARG_TYPE('err', 'Object', err); - return nr.getReport(err.stack); + return JSON.parse(nr.getReport(err.stack)); }, get directory() { return nr.getDirectory(); |