php-console icon indicating copy to clipboard operation
php-console copied to clipboard

ajax debugging problem

Open ground-creative opened this issue 11 years ago • 12 comments

I am not able to debug ajax scripts. I can see the headers PHP-Console-Postpone:{"protocol":5,"isPostponed":true,"id":"1362592614688597366942790441"} but the js does not seem to be picking it up. This started to happen only lately. Am I doing something wrong, or is there an issue with ajax debugging?

ground-creative avatar Jan 06 '15 15:01 ground-creative

Can you check if there are some JavaScript errors in extension console? There is tutorial how do get them https://github.com/barbushin/php-console/wiki/How-to-report-bug-or-feature#attach-google-chrome-extension-javascript-errors

barbushin avatar Jan 06 '15 15:01 barbushin

Very interesting, I see this in the errors console:

Unchecked runtime.lastError while running tabs.get: No tab with id: 711. at chrome-extension://nfhmhhlpfleoednkpnnnkolmclajemef/background.js:20:83

but what does it mean ?

ground-creative avatar Jan 06 '15 15:01 ground-creative

Is there any calls stack trace?

barbushin avatar Jan 06 '15 15:01 barbushin

No, only this:

Unchecked runtime.lastError while running tabs.get: No tab with id: 711. at chrome-extension://nfhmhhlpfleoednkpnnnkolmclajemef/background.js:20:83 handleResponse

And it keeps on adding this message to the infinite :(

ground-creative avatar Jan 06 '15 15:01 ground-creative

Hmm.. very very strange. Did you tried to restart browser? Reinstall extension? Can you give me the link to page where error occurs?

barbushin avatar Jan 06 '15 17:01 barbushin

I tried to restart he browser and reinstall the extension. If I change the js, the chrome complains that itwants to repair it and reinstalls a new version :( Unfortunately I cannot give you the link, I wish I could.

I clearly see the data in the session variable __PHP_Console_postponed and I also see the response header in the ajax request {"protocol":5,"isPostponed":true,"id":"12514339481623224091970918415"}

After restarting chrome (several times) the error has dissapeared but still no log to the console.

I now see the ajax request in the chrome extension console which makes me think that it is very strange like you say: __PHP_Console[getPostponedResponse]:5245160802017023721179324407

On page load the extesion logs just fine, it's only with ajax requests.

I am using a subdomain, bu I don't think that this is the issue.

Thanks for the help, I appreciate.

ground-creative avatar Jan 06 '15 17:01 ground-creative

Oh, yes, may be the problem is in subdomain. Can you test same code without subdomains? And what kind of data is logged in PHP Console? Is there some big data? Because phpconsole uses postponed requests only if total data size becomes > 4kb or 8kb(depends on web-server).

Also posponed requests starts when headers are sent before phpconsole is initialized. Is there any output before PhpConsole\Connector::getInstance() call?

barbushin avatar Jan 06 '15 19:01 barbushin

The problem seems to be with the postponed feature together with ajax.

If I only send 1 message it does work as it is not postponed.

I tried to use FILE( ) instead of SESSION( ) but it just creates an empty file.

No output is actually sent before \PhpConsole\Handler::getInstance( ) is called.

What could be wrong? Was the posponed feature also implement in earlier versions of the extension?

Would increasing the LimitRequestFieldsize help?

It would probably be better to address the problem by making the postponed feature work with ajax.

ground-creative avatar Jan 06 '15 20:01 ground-creative

Is AJAX request URL subdomain is different from original page domain?

Can you open URL that AJAX request calls directlty from browser address bar binding POST data manually in script?

What OS & Web-server do you use?

barbushin avatar Jan 07 '15 01:01 barbushin

Well, there were several issues. I had an annoying 502 gateway error which turn to be a problem with the server headers, I have apache with plesk and it seems as if the maximum is 4096 and not 8000. Also\PC::debug( ) just woudn't work ( I used register( ) ofcourse), I changed all the calls from the wrapper I have to \PhpConsole\Connector::getInstance( )->getDebugDispatcher( )->dispatchDebug( ) and that actually works.

Now the odd thing is that if I don't send any message in the first included file, no messages show up. I have set a dummy call at the very beginning of my application:

\PhpConsole\Connector::getInstance( )->getDebugDispatcher( )->dispatchDebug(' start patch' );

Without it, I see no messages in the consol even though the first include actually makes calls to the phpconsole.

Do you know what it could be? What could I have a look at?

ground-creative avatar Jan 07 '15 16:01 ground-creative

So many strange things with your code... Can you try http://php-console.com/instance/examples/ are all features works fine?

What framework do you use?

barbushin avatar Jan 07 '15 16:01 barbushin

I am not sure if this is entirely related, but I have had issues when dispatching a debug message from the server and then navigating (using POST) just after. In this case the debug notifications would come up in the client, but the console is empty.

The fix for my problem was modifying the extension content.js to store the url instead of the tab id.

In your case it could be extended to allow current url as well as several "white listed" ones. Several tabs with the same url will confuse this, of course.

rieva avatar Dec 06 '17 13:12 rieva