Chore: Make inject script more robust on repl & stream (#1429)
* try/catch injection of recording script in rrweb repl and stream * Add empty changesets
This commit is contained in:
2
.changeset/light-fireants-exercise.md
Normal file
2
.changeset/light-fireants-exercise.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
---
|
||||||
@@ -22,6 +22,7 @@ void (async () => {
|
|||||||
let events = [];
|
let events = [];
|
||||||
|
|
||||||
async function injectRecording(frame) {
|
async function injectRecording(frame) {
|
||||||
|
try {
|
||||||
await frame.evaluate((rrwebCode) => {
|
await frame.evaluate((rrwebCode) => {
|
||||||
const win = window;
|
const win = window;
|
||||||
if (win.__IS_RECORDING__) return;
|
if (win.__IS_RECORDING__) return;
|
||||||
@@ -56,6 +57,9 @@ void (async () => {
|
|||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
}, code);
|
}, code);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('failed to inject recording script:', e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await start('https://react-redux.realworld.io');
|
await start('https://react-redux.realworld.io');
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const pluginCode = fs.readFileSync(
|
|||||||
);
|
);
|
||||||
|
|
||||||
async function injectRecording(frame) {
|
async function injectRecording(frame) {
|
||||||
|
try {
|
||||||
await frame.evaluate(
|
await frame.evaluate(
|
||||||
(rrwebCode, pluginCode) => {
|
(rrwebCode, pluginCode) => {
|
||||||
const win = window;
|
const win = window;
|
||||||
@@ -48,14 +49,13 @@ async function injectRecording(frame) {
|
|||||||
|
|
||||||
win.events = [];
|
win.events = [];
|
||||||
window.record = win.rrweb.record;
|
window.record = win.rrweb.record;
|
||||||
window.plugin = new rrwebCanvasWebRTCRecord.RRWebPluginCanvasWebRTCRecord(
|
window.plugin =
|
||||||
{
|
new rrwebCanvasWebRTCRecord.RRWebPluginCanvasWebRTCRecord({
|
||||||
signalSendCallback: (msg) => {
|
signalSendCallback: (msg) => {
|
||||||
// [record#callback] provides canvas id, stream, and webrtc sdpOffer signal & connect message
|
// [record#callback] provides canvas id, stream, and webrtc sdpOffer signal & connect message
|
||||||
_signal(msg);
|
_signal(msg);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
window.record({
|
window.record({
|
||||||
emit: (event) => {
|
emit: (event) => {
|
||||||
@@ -73,6 +73,9 @@ async function injectRecording(frame) {
|
|||||||
code,
|
code,
|
||||||
pluginCode,
|
pluginCode,
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('failed to inject script, error:', e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startReplay(page, serverURL, recordedPage) {
|
async function startReplay(page, serverURL, recordedPage) {
|
||||||
|
|||||||
Reference in New Issue
Block a user