[Bug]: puppeteer @21.7.0 + vite@5.0.11 puppeteer bug
snail-boy opened this issue · comments
Preflight Checklist
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
What package is this bug report for?
rrweb
Version
2.0.0-alpha.11
Expected Behavior
my rrweb-project use vite for build dist . but puppeteer have some bug
大神求解!
Actual Behavior
使用跨域请求时iframe,
import puppeteer from 'puppeteer';
async function injectRecording(frame) {
await frame.evaluate((rrwebCode) => {
if (window.__IS_RECORDING__) return;
window.__IS_RECORDING__ = true;
(async () => {
function loadScript(code) {
const s = document.createElement('script');
s.type = 'text/javascript';
s.innerHTML = code;
if (document.head) {
document.head.append(s);
} else {
requestAnimationFrame(() => {
document.head.append(s);
});
}
}
loadScript(rrwebCode);
window.rrweb.record({
emit: (event) => {
window._captureEvent(event);
},
recordCrossOriginIframes: true,
});
})();
}, code);
}
const browser = await puppeteer.launch();
const page = (await browser.pages())[0];
const events = []; // 包含来自所有Frame的所有事件
await page.exposeFunction('_captureEvent', (event) => {
events.push(event);
});
page.on('framenavigated', async (frame) => {
await injectRecording(frame); // 将 rrweb 注入 iframe
});
await page.goto('https://example.com');
// 您的事件将在事件数组中
期望正常使用
Steps to Reproduce
上述代码应该在哪里引用阿
Testcase Gist URL
No response
Additional Information
No response
rrweb's runtime does not use puppeteer, this looks like a puppeteer + vite issue. Feel free to reopen this if further information about the rrweb part is needed.