Skip to content

Commit 2ff8edc

Browse files
committed
[#1796] update message structure sent from onerror and onunhandledrejection
1 parent dd433b7 commit 2ff8edc

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

client/utils/consoleUtils.js

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@ export const hijackConsoleErrorsScript = (offs) => {
2828
var fileInfo = getScriptOff(lineNumber);
2929
data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
3030
}
31-
window.parent.postMessage([{
32-
log: [{
33-
method: 'error',
34-
data: [data],
35-
id: Date.now().toString()
36-
}],
37-
source: fileInfo[1]
38-
}], '*');
31+
window.parent.postMessage(
32+
{
33+
source: fileInfo[1],
34+
messages: [
35+
{
36+
log: [
37+
{
38+
method: 'error',
39+
data: [data],
40+
id: Date.now().toString()
41+
}
42+
]
43+
}
44+
]
45+
}, '*');
3946
return false;
4047
};
4148
// catch rejected promises
@@ -44,14 +51,21 @@ export const hijackConsoleErrorsScript = (offs) => {
4451
var errorNum = event.reason.stack.split('about:srcdoc:')[1].split(':')[0];
4552
var fileInfo = getScriptOff(errorNum);
4653
var data = event.reason.message + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
47-
window.parent.postMessage([{
48-
log: [{
49-
method: 'error',
50-
data: [data],
51-
id: Date.now().toString()
52-
}],
53-
source: fileInfo[1]
54-
}], '*');
54+
window.parent.postMessage(
55+
{
56+
source: fileInfo[1],
57+
messages: [
58+
{
59+
log: [
60+
{
61+
method: 'error',
62+
data: [data],
63+
id: Date.now().toString()
64+
}
65+
]
66+
}
67+
]
68+
}, '*');
5569
}
5670
};
5771
`;
@@ -62,7 +76,7 @@ export const startTag = '@fs-';
6276

6377
export const getAllScriptOffsets = (htmlFile) => {
6478
const offs = [];
65-
const hijackConsoleErrorsScriptLength = 52;
79+
const hijackConsoleErrorsScriptLength = 66;
6680
const embeddedJSStart = 'script crossorigin=""';
6781
let foundJSScript = true;
6882
let foundEmbeddedJS = true;

0 commit comments

Comments
 (0)