pending-xhr-puppeteer icon indicating copy to clipboard operation
pending-xhr-puppeteer copied to clipboard

Destroy listener on page change

Open jtassin opened this issue 6 years ago • 5 comments
trafficstars

jtassin avatar Apr 04 '19 19:04 jtassin

any progress on this issue?

gtyang avatar Aug 02 '19 07:08 gtyang

Looking for this as well. Any news?

pcordon avatar Oct 27 '19 18:10 pcordon

@jtassin Ideally the listener should get disposed when waitForAllXhrFinished() promise gets resolved. Moreover page should start listening when we make call to waitForAllXhrFinished() instead of in constructor. This will stop unnecessary listening of requests.

Using this mechanism, we can use the same coding pattern as suggested by puppeteer -

await Promise.all([
  pendingXHR.waitForAllXhrFinished(), // Listeners will start listening requests
  page.click('a.my-link') // Click happened which triggered requests
]);

What do you think? I can raise the merge request if we agree.

agabhane avatar Nov 14 '19 08:11 agabhane

I have created new package @agabhane/puppeteer-pending-requests with above requirements and few enhancements.

agabhane avatar Jan 06 '20 06:01 agabhane

@agabhane your idea makes sense

Their is a PR for a cleanup behaviour : https://github.com/jtassin/pending-xhr-puppeteer/pull/112 more or less like your idea "listener should get disposed when waitForAllXhrFinished() promise gets resolved".

Your idea in puppeteer-pending-requests to add a timer is very good.

jtassin avatar Apr 26 '20 07:04 jtassin