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

Message added on visualize error on forceful termination #381

Merged
merged 11 commits into from
Feb 22, 2023
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ optimizations on background threads. With worker threads, the CPU will also
utilize more than 100%. The visible percentage is always the combination of all
these factors together.

__NOTE__: Exiting the process forcefully can result in wrong or no generation of log files.

### Windows + PowerShell

In order to diagnose your application with node clinic, you should execute your application after double hyphens(`--`),
Expand Down
1 change: 1 addition & 0 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ async function runTool (toolName, Tool, version, args, uiOptions) {
if (err) return defer.reject(err)

viz(toolName, filename, function (err) {
if (err?.code === 'ENOENT' && err?.message.includes('processstat')) return defer.reject(new Error('Process forcefully closed before processstat file generation'))
if (err) return defer.reject(err)
/* istanbul ignore if: isEnabled is always false when spawn process. See: https://github.com/sindresorhus/ora#isenabled */
if (spinner.isEnabled) {
Expand Down
17 changes: 17 additions & 0 deletions test/cli-doctor-forceful-termination.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const path = require('path')
const test = require('tap').test
const cli = require('./cli.js')

test('clinic doctor throws error when process is forcefully closed before processstat file is generated', { skip: process.version.startsWith('v14') }, function (t) {
// collect data
cli({}, [
'clinic', 'doctor', '--no-open',
'--', 'node', path.join(__dirname, 'forceful-termination.js')
], function (err, stdout, stderr) {
t.ok(err)
t.ok(stderr.includes('Process forcefully closed before processstat file generation'))
t.end()
})
})
14 changes: 14 additions & 0 deletions test/forceful-termination.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const async = require('async')

module.exports = function (exit) {
async.waterfall([
function (next) {
next()
},
function (next) {
next()
}
], exit)
}

!module.parent && module.exports(process.exit)