diff --git a/lib/internal/process/report.js b/lib/internal/process/report.js index 19820efa93ba02..251c32a109d55a 100644 --- a/lib/internal/process/report.js +++ b/lib/internal/process/report.js @@ -1,10 +1,9 @@ 'use strict'; -const { convertToValidSignal } = require('internal/util'); const { ERR_INVALID_ARG_TYPE, ERR_SYNTHETIC } = require('internal/errors').codes; -const { validateString } = require('internal/validators'); +const { validateSignalName, validateString } = require('internal/validators'); const nr = internalBinding('report'); const report = { writeReport(file, err) { @@ -47,8 +46,7 @@ const report = { return nr.getSignal(); }, set signal(sig) { - validateString(sig, 'signal'); - convertToValidSignal(sig); // Validate that the signal is recognized. + validateSignalName(sig, 'signal'); removeSignalHandler(); addSignalHandler(sig); nr.setSignal(sig); diff --git a/test/report/test-report-config.js b/test/report/test-report-config.js index 796f63d2b8caaf..6d33851416fdcc 100644 --- a/test/report/test-report-config.js +++ b/test/report/test-report-config.js @@ -68,7 +68,16 @@ if (!common.isWindows) { }, { code: 'ERR_INVALID_ARG_TYPE' }); common.expectsError(() => { process.report.signal = 'foo'; - }, { code: 'ERR_UNKNOWN_SIGNAL' }); + }, { + code: 'ERR_UNKNOWN_SIGNAL', + message: 'Unknown signal: foo' + }); + common.expectsError(() => { + process.report.signal = 'sigusr1'; + }, { + code: 'ERR_UNKNOWN_SIGNAL', + message: 'Unknown signal: sigusr1 (signals must use all capital letters)' + }); assert.strictEqual(process.report.signal, 'SIGUSR2'); process.report.signal = 'SIGUSR1'; assert.strictEqual(process.report.signal, 'SIGUSR1');