ulixee / secret-agent

The web scraper that's nearly impossible to block - now called @ulixee/hero
https://secretagent.dev
MIT License
667 stars 44 forks source link

Examining devtools commands #214

Open ghost opened 3 years ago

ghost commented 3 years ago

How do i see all devtools commands that are being sent and received? Puppeteer supports DEBUG env variable which turns verbose logging but in secret-agent setting that logs to console only a small portion of what's being sent back and forth.

blakebyrnes commented 3 years ago

You can see everything being sent by looking in the database for each session in the DevtoolsMessages table.

Session databases can be found here: https://secretagent.dev/docs/advanced/session

ghost commented 3 years ago

Yeah, that would do. But being able to simply output that to the console would be handier imho.

blakebyrnes commented 3 years ago

We used to output to console like Playwright/Pupp, but turned it off because it was just too much noise for normal debugging. There are a few other reasons I turned it off from default output logs:

  1. I frequently need to correlate log events with commands or resource events to figure out what was happening. That tends to be very challenging in console.
  2. It doesn't mix well with the rest of the logging, which output formatted json
  3. I found that if I turned on logging, it slowed down the process so much that sometimes it would stop triggering the events I wanted to investigate
  4. I frequently would have an issue and wanted to see what happened in devtools, but if I hadn't output to logs, I was out of luck

In any case, please let me know more about what you're trying to troubleshoot and why the db is less convenient. Will help me understand how to make this more useful to you.

ghost commented 3 years ago

Your points are valid. I just get used to pup's debugging when you redirect all output to text file and then open it in text editor and search events by target id or whatever. With sqlite i can do the same but with few extra steps, which is not a big deal.

I found that if I turned on logging, it slowed down the process so much that sometimes it would stop triggering the events I wanted to investigate

That's pretty disturbing. I wasn't aware of that.

ghost commented 3 years ago

To clarify, i meant being able to output to console alongside outputting to db. But yeah, that's probably would be handy only for me and few others.

blakebyrnes commented 3 years ago

That's pretty disturbing. I wasn't aware of that.

It was mostly just timing bugs that I couldn't reproduce, to be fair.

Your use case seems pretty normal when I think about it. I may have just gotten used to using the db at this point. Would you want to mix it in with all the other logs? Or are you just thinking it would be useful to route devtools specific logs off somewhere?

ghost commented 3 years ago

Would you want to mix it in with all the other logs?

Don't think it'll be a good idea. Unless it'd be possible to filter logs from different layers like it's done in pup.

Or are you just thinking it would be useful to route devtools specific logs off somewhere?

For me, yes )) But for others it can be useless. So, it's up to you.