Skip to content

Commit 1a88c3e

Browse files
TrottMylesBorins
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 95a95cc commit 1a88c3e

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
@@ -64,8 +64,15 @@ function parseWSFrame(buffer, handler) {
6464
}
6565
if (buffer.length < bodyOffset + dataLen)
6666
return 0;
67-
const message = JSON.parse(
68-
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8'));
67+
const jsonPayload =
68+
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8');
69+
let message;
70+
try {
71+
message = JSON.parse(jsonPayload);
72+
} catch (e) {
73+
console.error(`JSON.parse() failed for: ${jsonPayload}`);
74+
throw e;
75+
}
6976
if (DEBUG)
7077
console.log('[received]', JSON.stringify(message));
7178
handler(message);

0 commit comments

Comments
 (0)