`backgroundpage.on('console')` not working
See original GitHub issueSteps to reproduce
- Puppeteer version: 1.14.0
- Platform / OS version: macOS 10.14.3
- Node.js version: 11.6.0
What steps will reproduce the problem?
git clone https://github.com/pyrho/puppeteer-bug.git
yarn
node example.js
The repo for this issue: https://github.com/pyrho/puppeteer-bug
What is the expected result?
Messages (console.log
)from the background page are caught by the backgroundPage.on('console')
handler.
`bg: PORT CONNECTED" should print in the node console.
What happens instead? Messages are not caught by the handler.
When manually inspecting the background page, we can see that the message is printed in the console tab:
Thank you for your time and this awesome project 😃
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Accessing console and devtools of extension's background.js
Enable developer mode ; Click on the link named background page (ManifestV2) or service worker (ManifestV3). Screenshot for ManifestV2 extensions ...
Read more >extension.getBackgroundPage() - Mozilla - MDN Web Docs
Returns the Window of the background page if the background script is running. If the script is not running, null is returned.
Read more >Console Stops Working - Google Groups
I'm developing a Chrome extension, and have run into a strange problem when trying to debug: When I go to my extension in...
Read more >chrome.runtime - Chrome Developers
Use the chrome.runtime API to retrieve the background page, return details about the manifest, and listen for and respond to events in the...
Read more >How To: Obtain diagnostic logs from Umbrella Chromebook ...
Clear console by running "Ctrl + L" before reproducing the issue. ... as is best practice) the background page is not available for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We should disable the component extensions by default - submitted the https://github.com/GoogleChrome/puppeteer/pull/4704 for this.
Indeed my bad. So, excuse my english, i’m pretty bad at explaining things but i’ll try since i got those bg messages. I think the issue is that there is two background pages, i actually got your example working once, but only once so that was strange, then i tried to output all console messages from all targets, it crashed so by filtering with only the targets that seems to be a background page, that works. If you add this right after the
console.log('closing');
line in your example :You can see the messages that way.
I think you can get rid of most of the code and use
.on('console', msg => console.log(
bg: ${msg.text()}));
The
console.log(test[i]);
outputs two background pages, and since i added the listener to both i don’t know witch one is the correct one i did not dig enough into that, but you should be able to filter the correct one. Like if you take a look at the target objects, there are easy ways to differentiates both of them like i think one has your extension name inside. I don’t know if having two background pages when you specify--disable-extensions-except
is normal behavior.I don’t know if that make sense, i hope it does. EDIT: typo and maybe more clear.