Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c53b4ad
lib: add primordials.SafeArrayIterator
aduh95 Dec 6, 2020
1355e52
Revert "debugger: rename internal library for clarity"
aduh95 Jul 20, 2021
7b5e17f
debugger: add usage example for `--port`
RafaelGSS Jul 27, 2020
8146a8c
debugger: refactor `internal/inspector/_inspect` to use more primordials
aduh95 Apr 25, 2021
cc589f3
debugger: wait for V8 debugger to be enabled
targos May 26, 2021
e036082
debugger: revise async iterator usage to comply with lint rules
Trott May 29, 2021
e622105
debugger: reduce scope of eslint disable comment
Trott Jun 6, 2021
9b960d9
debugger: enable linter on `internal/inspector/inspect_client`
aduh95 Apr 26, 2021
5ae4a50
debugger: remove unnecessary boilerplate copyright comment
Trott Jun 6, 2021
ccc69e0
debugger: align message with Node.js standard
Trott Sep 19, 2020
8b16b82
debugger: wrap lines longer than 80 chars
Trott May 4, 2021
62131f6
debugger: avoid non-ASCII char in code file
Trott May 4, 2021
d025841
debugger: disable only the lint rules required by current file state
Trott May 4, 2021
e86361a
debugger: refactor to use internal modules
aduh95 May 5, 2021
22320ed
debugger: refactor `inspect_repl` to use primordials
aduh95 Apr 27, 2021
f41d010
debugger: removed unused function argument
Trott May 30, 2021
7a5e902
errors: add ERR_DEBUGGER_ERROR
Trott Jun 13, 2021
beb3dce
debugger: use ERR_DEBUGGER_ERROR in debugger client
Trott Jun 13, 2021
a4c42b5
debugger: use error codes in debugger REPL
Trott Jun 13, 2021
584f779
errors: add ERR_DEBUGGER_STARTUP_ERROR
Trott Jun 13, 2021
f5dd504
debugger: use ERR_DEBUGGER_STARTUP_ERROR in _inspect.js
Trott Jun 13, 2021
2e8360e
debugger: rename internal library for clarity
Trott Jun 19, 2021
1211825
fixup! lib: add primordials.SafeArrayIterator
aduh95 Jul 20, 2021
9cd07e1
fixup! debugger: add usage example for `--port`
aduh95 Jul 20, 2021
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
Prev Previous commit
Next Next commit
debugger: use ERR_DEBUGGER_ERROR in debugger client
PR-URL: #39024
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
  • Loading branch information
Trott authored and aduh95 committed Jul 20, 2021
commit beb3dce4248edf3db348b30ed93cc7d493638f1d
32 changes: 17 additions & 15 deletions lib/internal/inspector/inspect_client.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// TODO(aduh95): use errors exported by the internal/errors module
/* eslint-disable no-restricted-syntax */

'use strict';

const {
ArrayPrototypePush,
Error,
ErrorCaptureStackTrace,
FunctionPrototypeBind,
JSONParse,
Expand All @@ -15,6 +11,7 @@ const {
} = primordials;

const Buffer = require('buffer').Buffer;
const { ERR_DEBUGGER_ERROR } = require('internal/errors').codes;
const { EventEmitter } = require('events');
const http = require('http');
const URL = require('url');
Expand All @@ -39,7 +36,7 @@ const kEightBytePayloadLengthField = 127;
const kMaskingKeyWidthInBytes = 4;

function unpackError({ code, message, data }) {
const err = new Error(`${message} - ${data}`);
const err = new ERR_DEBUGGER_ERROR(`${message} - ${data}`);
err.code = code;
ErrorCaptureStackTrace(err, unpackError);
return err;
Expand Down Expand Up @@ -101,14 +98,14 @@ function decodeFrameHybi17(data) {
const masked = (secondByte & kMaskBit) !== 0;
const compressed = reserved1;
if (compressed) {
throw new Error('Compressed frames not supported');
throw new ERR_DEBUGGER_ERROR('Compressed frames not supported');
}
if (!final || reserved2 || reserved3) {
throw new Error('Only compression extension is supported');
throw new ERR_DEBUGGER_ERROR('Only compression extension is supported');
}

if (masked) {
throw new Error('Masked server frame - not supported');
throw new ERR_DEBUGGER_ERROR('Masked server frame - not supported');
}

let closed = false;
Expand All @@ -119,7 +116,7 @@ function decodeFrameHybi17(data) {
case kOpCodeText:
break;
default:
throw new Error(`Unsupported op code ${opCode}`);
throw new ERR_DEBUGGER_ERROR(`Unsupported op code ${opCode}`);
}

let payloadLength = secondByte & kPayloadLengthMask;
Expand Down Expand Up @@ -183,7 +180,9 @@ class Client extends EventEmitter {
debuglog('< %s', payloadStr);
const lastChar = payloadStr[payloadStr.length - 1];
if (payloadStr[0] !== '{' || lastChar !== '}') {
throw new Error(`Payload does not look like JSON: ${payloadStr}`);
throw new ERR_DEBUGGER_ERROR(
`Payload does not look like JSON: ${payloadStr}`
);
}
let payload;
try {
Expand All @@ -204,7 +203,7 @@ class Client extends EventEmitter {
this.emit('debugEvent', method, params);
this.emit(method, params);
} else {
throw new Error(`Unsupported response: ${payloadStr}`);
throw new ERR_DEBUGGER_ERROR(`Unsupported response: ${payloadStr}`);
}
}
}
Expand All @@ -226,7 +225,7 @@ class Client extends EventEmitter {
callMethod(method, params) {
return new Promise((resolve, reject) => {
if (!this._socket) {
reject(new Error('Use `run` to start the app again.'));
reject(new ERR_DEBUGGER_ERROR('Use `run` to start the app again.'));
return;
}
const data = { id: ++this._lastId, method, params };
Expand Down Expand Up @@ -254,14 +253,17 @@ class Client extends EventEmitter {
function parseChunks() {
const resBody = Buffer.concat(chunks).toString();
if (httpRes.statusCode !== 200) {
reject(new Error(`Unexpected ${httpRes.statusCode}: ${resBody}`));
reject(new ERR_DEBUGGER_ERROR(
`Unexpected ${httpRes.statusCode}: ${resBody}`
));
return;
}
try {
resolve(JSONParse(resBody));
} catch {
reject(new Error(`Response didn't contain JSON: ${resBody}`));

reject(new ERR_DEBUGGER_ERROR(
`Response didn't contain JSON: ${resBody}`
));
}
}

Expand Down