Skip to content

Commit 74ab1aa

Browse files
cjihrigBridgeAR
authored andcommitted
report: rename triggerReport() to writeReport()
writeReport() is more descriptive of what the function does. PR-URL: #26527 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 0f8d8d6 commit 74ab1aa

File tree

7 files changed

+29
-30
lines changed

7 files changed

+29
-30
lines changed

Diff for: doc/api/process.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ The signal used to trigger the creation of a diagnostic report. Defaults to
17721772
console.log(`Report signal: ${process.report.signal}`);
17731773
```
17741774

1775-
### process.report.triggerReport([filename][, err])
1775+
### process.report.writeReport([filename][, err])
17761776
<!-- YAML
17771777
added: v11.8.0
17781778
-->
@@ -1790,7 +1790,7 @@ filename includes the date, time, PID, and a sequence number. The report's
17901790
JavaScript stack trace is taken from `err`, if present.
17911791

17921792
```js
1793-
process.report.triggerReport();
1793+
process.report.writeReport();
17941794
```
17951795

17961796
Additional documentation is available in the [report documentation][].

Diff for: doc/api/report.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,14 @@ written.
404404
A report can also be triggered via an API call from a JavaScript application:
405405

406406
```js
407-
process.report.triggerReport();
407+
process.report.writeReport();
408408
```
409409

410410
This function takes an optional additional argument `filename`, which is
411411
the name of a file into which the report is written.
412412

413413
```js
414-
process.report.triggerReport('./foo.json');
414+
process.report.writeReport('./foo.json');
415415
```
416416

417417
This function takes an optional additional argument `err` - an `Error` object
@@ -424,19 +424,19 @@ as where it was handled.
424424
try {
425425
process.chdir('/non-existent-path');
426426
} catch (err) {
427-
process.report.triggerReport(err);
427+
process.report.writeReport(err);
428428
}
429429
// Any other code
430430
```
431431

432-
If both filename and error object are passed to `triggerReport()` the
432+
If both filename and error object are passed to `writeReport()` the
433433
error object must be the second parameter.
434434

435435
```js
436436
try {
437437
process.chdir('/non-existent-path');
438438
} catch (err) {
439-
process.report.triggerReport(filename, err);
439+
process.report.writeReport(filename, err);
440440
}
441441
// Any other code
442442
```
@@ -470,7 +470,7 @@ triggered using the Node.js REPL:
470470

471471
```raw
472472
$ node
473-
> process.report.triggerReport();
473+
> process.report.writeReport();
474474
Writing Node.js report to file: report.20181126.091102.8480.001.json
475475
Node.js report completed
476476
>

Diff for: lib/internal/process/execution.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ function createFatalException() {
110110
try {
111111
const report = internalBinding('report');
112112
if (report != null && report.shouldReportOnUncaughtException()) {
113-
report.triggerReport(er ? er.message : 'Exception',
114-
'Exception',
115-
null,
116-
er ? er.stack : undefined);
113+
report.writeReport(er ? er.message : 'Exception',
114+
'Exception',
115+
null,
116+
er ? er.stack : undefined);
117117
}
118118
} catch {} // Ignore the exception. Diagnostic reporting is unavailable.
119119
}

Diff for: lib/internal/process/report.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const {
77
const { validateString } = require('internal/validators');
88
const nr = internalBinding('report');
99
const report = {
10-
triggerReport(file, err) {
10+
writeReport(file, err) {
1111
if (typeof file === 'object' && file !== null) {
1212
err = file;
1313
file = undefined;
@@ -19,7 +19,7 @@ const report = {
1919
throw new ERR_INVALID_ARG_TYPE('err', 'Object', err);
2020
}
2121

22-
return nr.triggerReport('JavaScript API', 'API', file, err.stack);
22+
return nr.writeReport('JavaScript API', 'API', file, err.stack);
2323
},
2424
getReport(err) {
2525
if (err === undefined)
@@ -101,7 +101,7 @@ function removeSignalHandler() {
101101
}
102102

103103
function signalHandler(sig) {
104-
nr.triggerReport(sig, 'Signal', null, '');
104+
nr.writeReport(sig, 'Signal', null, '');
105105
}
106106

107107
module.exports = {

Diff for: src/node_report.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ std::string ValueToHexString(T value) {
6767
}
6868

6969
// Function declarations - export functions in src/node_report_module.cc
70-
void TriggerReport(const v8::FunctionCallbackInfo<v8::Value>& info);
70+
void WriteReport(const v8::FunctionCallbackInfo<v8::Value>& info);
7171
void GetReport(const v8::FunctionCallbackInfo<v8::Value>& info);
7272

7373
// Node.js boot time - defined in src/node.cc

Diff for: src/node_report_module.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ using v8::Object;
3030
using v8::String;
3131
using v8::Value;
3232

33-
// External JavaScript API for triggering a report
34-
void TriggerReport(const FunctionCallbackInfo<Value>& info) {
33+
void WriteReport(const FunctionCallbackInfo<Value>& info) {
3534
Environment* env = Environment::GetCurrent(info);
3635
Isolate* isolate = env->isolate();
3736
HandleScope scope(isolate);
@@ -161,7 +160,7 @@ static void Initialize(Local<Object> exports,
161160
Local<Context> context) {
162161
Environment* env = Environment::GetCurrent(context);
163162

164-
env->SetMethod(exports, "triggerReport", TriggerReport);
163+
env->SetMethod(exports, "writeReport", WriteReport);
165164
env->SetMethod(exports, "getReport", GetReport);
166165
env->SetMethod(exports, "getDirectory", GetDirectory);
167166
env->SetMethod(exports, "setDirectory", SetDirectory);

Diff for: test/report/test-report-triggerreport.js renamed to test/report/test-report-writereport.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ function validate() {
2727

2828
{
2929
// Test with no arguments.
30-
process.report.triggerReport();
30+
process.report.writeReport();
3131
validate();
3232
}
3333

3434
{
3535
// Test with an error argument.
36-
process.report.triggerReport(new Error('test error'));
36+
process.report.writeReport(new Error('test error'));
3737
validate();
3838
}
3939

4040
{
4141
// Test with a file argument.
42-
const file = process.report.triggerReport('custom-name-1.json');
42+
const file = process.report.writeReport('custom-name-1.json');
4343
const absolutePath = path.join(tmpdir.path, file);
4444
assert.strictEqual(helper.findReports(process.pid, tmpdir.path).length, 0);
4545
assert.strictEqual(file, 'custom-name-1.json');
@@ -49,8 +49,8 @@ function validate() {
4949

5050
{
5151
// Test with file and error arguments.
52-
const file = process.report.triggerReport('custom-name-2.json',
53-
new Error('test error'));
52+
const file = process.report.writeReport('custom-name-2.json',
53+
new Error('test error'));
5454
const absolutePath = path.join(tmpdir.path, file);
5555
assert.strictEqual(helper.findReports(process.pid, tmpdir.path).length, 0);
5656
assert.strictEqual(file, 'custom-name-2.json');
@@ -61,7 +61,7 @@ function validate() {
6161
{
6262
// Test with a filename option.
6363
process.report.filename = 'custom-name-3.json';
64-
const file = process.report.triggerReport();
64+
const file = process.report.writeReport();
6565
assert.strictEqual(helper.findReports(process.pid, tmpdir.path).length, 0);
6666
const filename = path.join(process.report.directory, 'custom-name-3.json');
6767
assert.strictEqual(file, process.report.filename);
@@ -72,21 +72,21 @@ function validate() {
7272
// Test with an invalid file argument.
7373
[null, 1, Symbol(), function() {}].forEach((file) => {
7474
common.expectsError(() => {
75-
process.report.triggerReport(file);
75+
process.report.writeReport(file);
7676
}, { code: 'ERR_INVALID_ARG_TYPE' });
7777
});
7878

7979
// Test with an invalid error argument.
8080
[null, 1, Symbol(), function() {}, 'foo'].forEach((error) => {
8181
common.expectsError(() => {
82-
process.report.triggerReport('file', error);
82+
process.report.writeReport('file', error);
8383
}, { code: 'ERR_INVALID_ARG_TYPE' });
8484
});
8585

8686
{
8787
// Test the special "stdout" filename.
8888
const args = ['--experimental-report', '-e',
89-
'process.report.triggerReport("stdout")'];
89+
'process.report.writeReport("stdout")'];
9090
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
9191
assert.strictEqual(child.status, 0);
9292
assert.strictEqual(child.signal, null);
@@ -97,7 +97,7 @@ function validate() {
9797
{
9898
// Test the special "stderr" filename.
9999
const args = ['--experimental-report', '-e',
100-
'process.report.triggerReport("stderr")'];
100+
'process.report.writeReport("stderr")'];
101101
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
102102
assert.strictEqual(child.status, 0);
103103
assert.strictEqual(child.signal, null);
@@ -113,7 +113,7 @@ function validate() {
113113
const args = ['--experimental-report',
114114
`--diagnostic-report-directory=${reportDir}`,
115115
'-e',
116-
'process.report.triggerReport()'];
116+
'process.report.writeReport()'];
117117
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
118118

119119
assert.strictEqual(child.status, 0);

0 commit comments

Comments
 (0)