Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
debugger: refactor console in lib/internal/debugger/inspect.js
Refs: #38406
  • Loading branch information
debadree25 committed Dec 13, 2022
commit ff12980b67495964563118418f88e66a5819b17d
26 changes: 13 additions & 13 deletions lib/internal/debugger/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ const {
AbortController,
} = require('internal/abort_controller');

// TODO(aduh95): remove console calls
const console = require('internal/console/global');

const { 0: InspectClient, 1: createRepl } =
[
require('internal/debugger/inspect_client'),
Expand Down Expand Up @@ -319,7 +316,7 @@ function parseArgv(args) {
process._debugProcess(pid);
} catch (e) {
if (e.code === 'ESRCH') {
console.error(`Target process: ${pid} doesn't exist.`);
process.stderr.write(`Target process: ${pid} doesn't exist.\n`);
process.exit(kGenericUserError);
}
throw e;
Expand All @@ -339,10 +336,10 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
if (argv.length < 1) {
const invokedAs = `${process.argv0} ${process.argv[1]}`;

console.error(`Usage: ${invokedAs} script.js`);
console.error(` ${invokedAs} <host>:<port>`);
console.error(` ${invokedAs} --port=<port>`);
console.error(` ${invokedAs} -p <pid>`);
process.stderr.write(`Usage: ${invokedAs} script.js\n`);
process.stderr.write(` ${invokedAs} <host>:<port>\n`);
process.stderr.write(` ${invokedAs} --port=<port>\n`);
process.stderr.write(` ${invokedAs} -p <pid>\n`);
Comment thread
debadree25 marked this conversation as resolved.
Outdated
// TODO(joyeecheung): should be kInvalidCommandLineArgument.
process.exit(kGenericUserError);
}
Expand All @@ -354,12 +351,15 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),

function handleUnexpectedError(e) {
if (e.code !== 'ERR_DEBUGGER_STARTUP_ERROR') {
console.error('There was an internal error in Node.js. ' +
'Please report this bug.');
console.error(e.message);
console.error(e.stack);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There would be a difference if the inspect client listens to Runtime.consoleAPICalled, but I don't think it does currently.

process.stderr.write('There was an internal error in Node.js. ' +
'Please report this bug.\n');
process.stderr.write(e.message);
process.stderr.write('\n');
process.stderr.write(e.stack);
process.stderr.write('\n');
Comment thread
debadree25 marked this conversation as resolved.
Outdated
} else {
console.error(e.message);
process.stderr.write(e.message);
process.stderr.write('\n');
}
if (inspector.child) inspector.child.kill();
process.exit(kGenericUserError);
Expand Down