Skip to content

Commit 15b9aa1

Browse files
Trottaddaleax
authored andcommitted
test: improve error logging for inspector test
If JSON.parse() fails, print a message showing the JSON that failed to parse. This is to help with debugging a current test failure on CI. PR-URL: #14508 Ref: #14507 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent 451e643 commit 15b9aa1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/inspector/inspector-helper.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ function parseWSFrame(buffer, handler) {
7373
}
7474
if (buffer.length < bodyOffset + dataLen)
7575
return 0;
76-
const message = JSON.parse(
77-
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8'));
76+
const jsonPayload =
77+
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8');
78+
let message;
79+
try {
80+
message = JSON.parse(jsonPayload);
81+
} catch (e) {
82+
console.error(`JSON.parse() failed for: ${jsonPayload}`);
83+
throw e;
84+
}
7885
if (DEBUG)
7986
console.log('[received]', JSON.stringify(message));
8087
handler(message);

0 commit comments

Comments
 (0)