adriancooney / puppeteer-heap-snapshot

API and CLI tool to fetch and query Chome DevTools heap snapshots.
MIT License
1.35k stars 68 forks source link

Wait for selector instead of timeout #9

Closed melusc closed 1 year ago

melusc commented 1 year ago

I think waiting a set amount of time before capturing a snapshot is not ideal.

Instead I think using Page.waitForSelector() might work better. This means that once the data is loaded and rendered you can capture it without wasting any time. To use this option there'd be a flag like --selector (and perhaps -s) that is passed to the function above directly.

I would be happy to try implementing this but before I would like some opinions on some details:

  1. Should there also be an option for Page.waitForXPath()? (--xpath?)
  2. Timeout
    1. Should it timeout at some point? After 10s or more?
    2. Should it throw on timeout?

Personally, I don't see the need for XPath.
I think it should timeout, but maybe after 30s or so by default and be overridable with --wait.
I'm not too sure about throwing, but it might be beneficial to know that it timed out.