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.

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: unexpected server response (500)

See original GitHub issue

I want to do something on several tabs, so here is my code:

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

var Tab = ( function()  {
      process : function(url){
			CDP.New({'url':url}, function (err, target) {				
				if (!err) {
					CDP((client) => {
						const {Network, Page, Runtime} = client;
						Network.enable();
						Page.enable();
						Runtime.enable();
                                                Page.navigate({url: URL});
                                                     ....
                                                do something
                                        });
                                 }
                           });
        }
})();

function openUrl(url) {		     		
        var tab = new Tab();
        tab.process(url);   
}
openUrl('http://github.com');
openUrl('http://google.com');

Then error: (node:8700) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: unexpected server response (500)

image

The function openUrl() will be called when there are some post requests. Therefore, I use two lines of openUrl() to represent.

I think the error may be happened when

CDP( (client) =>{          
});

Is CDP() just allow being used once? How can I deal with the muli-tab problem? I need to do something on different tabs asynchronously…

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
cyrus-andcommented, Apr 27, 2017

This works fine for me, can you try it?

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

var Tab = function () {
    return {
        process: function (url) {
            CDP.New({'url':url}, function (err, target) {
                console.log(target);
                if (!err) {
                    CDP({target}, (client) => {
                        const {Network, Page, Runtime} = client;
                        Network.enable();
                        Page.enable();
                        Runtime.enable();
                        Page.navigate({url: url});
                        console.log('do something');
                    });
                }
            });
        }
    };
};

function openUrl(url) {
    var tab = new Tab();
    tab.process(url);
}

openUrl('http://github.com');
openUrl('http://google.com');
0reactions
cyrus-andcommented, Apr 27, 2017

OK, that’s because I suggested to use the target option which has been introduced in v0.20.0 while you were using an older release (which uses tab instead). You’re welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnhandledPromiseRejectionWar...
Error : UnhandledPromiseRejectionWarning: Unhandled promise rejection · It usually means that you're calling res. · I don't call res. · After ...
Read more >
Unhandled Promise Rejections in Node.js - The Code Barbarian
Output $ node test.js (node:8383) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: exception!
Read more >
Handling those unhandled promise rejections with JS async ...
One of your await ed functions fails (i.e. rejects a promise); You get the error. Another possibility is that you know you need...
Read more >
500 Internal Server Error when loading tasks - GenieACS Forum
But it fails with HTTP error 500, and body content: ... To terminate the node process on unhandled promise rejection, use the CLI...
Read more >
Node.js v19.3.0 Documentation
SyncWriteStream; DEP0062: node --debug; DEP0063: ServerResponse.prototype. ... doesNotReject() will return a rejected Promise with that error.
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