From c6829ec649bf376f1fe24ceec864fb1c90e1e285 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 28 Jul 2021 20:55:50 -0700 Subject: [PATCH 1/2] debugger: remove undefined parameter The data parameter of unpackError() is typically undefined. --- lib/internal/debugger/inspect_client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/debugger/inspect_client.js b/lib/internal/debugger/inspect_client.js index 419b984cc9f473..5c72304ba285c3 100644 --- a/lib/internal/debugger/inspect_client.js +++ b/lib/internal/debugger/inspect_client.js @@ -40,8 +40,8 @@ const kMaskingKeyWidthInBytes = 4; // https://tools.ietf.org/html/rfc6455#section-1.3 const WEBSOCKET_HANDSHAKE_GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'; -function unpackError({ code, message, data }) { - const err = new ERR_DEBUGGER_ERROR(`${message} - ${data}`); +function unpackError({ code, message }) { + const err = new ERR_DEBUGGER_ERROR(`${message}`); err.code = code; ErrorCaptureStackTrace(err, unpackError); return err; From 30d00ef38dea2a5b49c6eb93bba1a2b1ee81c705 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 28 Jul 2021 20:56:11 -0700 Subject: [PATCH 2/2] test: add test-debugger-breakpoint-exists This adds test coverage to `unpackError()` in `lib/internal/debugger/inspect_client.js`. That function previously was untested. --- .../test-debugger-breakpoint-exists.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/sequential/test-debugger-breakpoint-exists.js diff --git a/test/sequential/test-debugger-breakpoint-exists.js b/test/sequential/test-debugger-breakpoint-exists.js new file mode 100644 index 00000000000000..7be0ba657fa981 --- /dev/null +++ b/test/sequential/test-debugger-breakpoint-exists.js @@ -0,0 +1,27 @@ +'use strict'; + +const common = require('../common'); + +common.skipIfInspectorDisabled(); + +const fixtures = require('../common/fixtures'); +const startCLI = require('../common/debugger'); + +// Test for "Breakpoint at specified location already exists" error. +{ + const script = fixtures.path('debugger', 'three-lines.js'); + const cli = startCLI([script]); + + function onFatal(error) { + cli.quit(); + throw error; + } + + cli.waitForInitialBreak() + .then(() => cli.waitForPrompt()) + .then(() => cli.command('setBreakpoint(1)')) + .then(() => cli.command('setBreakpoint(1)')) + .then(() => cli.waitFor(/Breakpoint at specified location already exists/)) + .then(() => cli.quit()) + .then(null, onFatal); +}