feat: rerender on network requests

This commit is contained in:
Rohit
2025-06-30 16:15:52 +05:30
parent f17c7299e3
commit eecfa43198

View File

@@ -435,19 +435,36 @@ export class RemoteBrowser {
await this.makeAndEmitDOMSnapshot(); await this.makeAndEmitDOMSnapshot();
}); });
// DO NOT REMOVE THIS CODE - MIGHT BE NEEDED LATER this.currentPage.on("response", async (response) => {
// this.currentPage.on("response", async (response) => { const url = response.url();
// const url = response.url(); if (
// if ( response.request().resourceType() === "document" ||
// response.request().resourceType() === "document" || url.includes("api/") ||
// url.includes("api/") || url.includes("ajax")
// url.includes("ajax") ) {
// ) { this.pendingNetworkRequests.push(url);
// setTimeout(async () => {
// await this.makeAndEmitDOMSnapshot(); if (this.networkRequestTimeout) {
// }, 800); clearTimeout(this.networkRequestTimeout);
// } this.networkRequestTimeout = null;
// }); }
logger.debug(
`Network request received: ${url}. Total pending: ${this.pendingNetworkRequests.length}`
);
this.networkRequestTimeout = setTimeout(async () => {
logger.info(
`Network quiet period reached. Processing ${this.pendingNetworkRequests.length} requests`
);
this.pendingNetworkRequests = [];
this.networkRequestTimeout = null;
await this.makeAndEmitDOMSnapshot();
}, this.NETWORK_QUIET_PERIOD);
}
});
} }
private async setupPageEventListeners(page: Page) { private async setupPageEventListeners(page: Page) {