question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get js errors from the site

See original GitHub issue

I try to get js errors from the sites:

CDP(async (client) => {
    const {Log, Page, Runtime, Network, Console} = client;
    try {
        await Network.enable();
        await Page.enable();

        await Log.enable();
        await Log.clear();
        Log.entryAdded(({entry}) => {
            console.log(entry);
            /*if (entry.level === 'error' && entry.source === 'javascript') {
                console.log(entry);
            }*/
        });

        await Console.enable();
        await Console.clearMessages();
        Console.messageAdded(({entry}) => {
            console.log(entry);
            /*if (entry != undefined && entry.level === 'error' && entry.source === 'javascript') {
                console.log(entry);
            }*/
        })

        await Page.navigate({url: url});
        await Page.loadEventFired();

        //console.log(html);
    } catch (err) {
        console.error(err);
    } finally {
        client.close();
    }

})

But methods Log.entryAdded and Console.messageAdded don’t want to give errors from some sites, for example - crucial.com.au or note.ly And Console.messageAdded - just returns undefined.

Perhaps someone knows how to get js errors correctly? Thanks.

Component Version
Operating system Ubuntu
Node.js Node.js v7.10.0
Chrome/Chromium/… 59.0.3071.36
chrome-remote-interface 0.22.0

Is Chrome running in a container? NO

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cyrus-andcommented, Aug 26, 2017

According to that thread the solution is using Runtime.exceptionThrown and it actually works for me:

const CDP = require('chrome-remote-interface');

CDP(async (client) => {
    const {Page, Runtime} = client;
    try {
        await Page.enable();
        await Runtime.enable();
        await Page.navigate({url: 'http://note.ly'});
        // this needs to be registered after the page load command in order to
        // avoid showing exceptions from the previous page state
        Runtime.exceptionThrown((params) => {
            console.log('>', params);
        });
        await Page.loadEventFired();
    } catch (err) {
        console.error(err);
    } finally {
        client.close();
    }
});
1reaction
bookincommented, Aug 25, 2017

Thanks for response, for first I created a message on the Google Group

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Your Browser to Diagnose JavaScript Errors
Go to the screen where you are experiencing the error. In Chrome, navigate to Tools > Advanced > Error Console. ... The error...
Read more >
How to find JavaScript errors with your browser's console?
If you suspect that an issue on your website is caused by a JavaScript error, there luckily is an easy way to check...
Read more >
Get all javascript errors on page/javascript error handling
I have mine working with window. onerror and it doesn't stop my javascript: window. onerror = function(error, url, line) { controller.
Read more >
How Do I Diagnose JavaScript Errors on My Site?
Open Google Chrome. · Click the “Customize and Control Google Chrome” button at the top right side. · Chrome tools Error Console. From...
Read more >
JavaScript errors page: Detect and analyze errors
View JavaScript errors · Go to one.newrelic.com > Browser > (select an app) > JS errors. · Use the available options in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found