debug_kit icon indicating copy to clipboard operation
debug_kit copied to clipboard

XHR requests in the history panels are not updating

Open boyerdalton opened this issue 4 years ago • 8 comments

Php version: 7.2.4

Cakephp version:3.9.5

Debugkit version:3.22.4

Development setup: Done through vagrant with a development url in this format site.subdomain.com

Install steps: The ones provided on The cakephp cookbook with addition of

if (Configure::read('debug')) {
    Configure::write('DebugKit', ['forceEnable' => true]);
    Plugin::load('DebugKit', ['bootstrap' => true]);

}

It appears that I am having an issue with getting the debugkit to display XHR requests in the History panel. They are being logged into MYSQL database and can be accessed once I refresh my browser, but do not update when they happen as shown on this article. It also appears that not all XHR requests are even being shown in the History panel when I Refresh. The requests that I make is just through simple Jquery Ajax, and I even tried to make a request in the manner that was shown on that video in that link. My question is do I have to configure something else to get this to show, or should it just show automaticlly. I am attaching a screenshot to show you what happens when I make an ajax call in the console (*note I have covered my base url in the screenshot and replaced it with a url that is in the same format and manner as mine).

image

boyerdalton avatar Jan 07 '21 01:01 boyerdalton

If your requests end up going through fetch() DebugKit will not be able to capture them. The live logging relies on patching XMLHttpRequest and it is possible for libraries to obtain a reference to that object before DebugKit can apply its patches.

markstory avatar Jan 07 '21 14:01 markstory

If your requests end up going through fetch() DebugKit will not be able to capture them. The live logging relies on patching XMLHttpRequest and it is possible for libraries to obtain a reference to that object before DebugKit can apply its patches.

@markstory it is an XMLHttpRequest, as it is just a jquery ajax call. I only use ajax in this codebase, I don't use fetch() anywhere in it.

boyerdalton avatar Jan 07 '21 17:01 boyerdalton

https://github.com/cakephp/debug_kit/blob/master/webroot/js/toolbar.js#L60-L117 Is the code that adds the proxy. I'm not able to reproduce your problem so you'll need to help find the problem :smile:

markstory avatar Jan 07 '21 20:01 markstory

Thanks @markstory so I did some testing around and it seems that this.getResponseHeader('X-DEBUGKIT-ID') on line 62 of toolbar.js is returning as null.

boyerdalton avatar Jan 07 '21 23:01 boyerdalton

Are there warnings in the browser console about forbidden access to headers? That header should be set by the Middleware in DebugKit when it saves a request.

markstory avatar Jan 08 '21 02:01 markstory

@markstory there are no warnings in the console. When I console logged getAllResponseHeaders (), and X-DEBUGKIT-ID Is not even present in the list of headers. I consulted another dev about this at my job, as he uses debugkit on 2 other products, and he didn’t even know it could log XHR request because his requests are not updating either. I use Firefox and he uses chrome, I don’t know if that helps or not.

boyerdalton avatar Jan 08 '21 02:01 boyerdalton

Could there be a webserver or proxy that is stripping the response header? I tried tonight with the bin/cake server webserver and was able to capture requests in the history panel. screenshot - 2021-01-08 23:01:42

markstory avatar Jan 09 '21 04:01 markstory

@markstory Yeah I'm not sure whats going on here, I debug( $response->withBody($body)) in ToolbarServices in injectScripts and it does have the X-DEBUGKIT-ID in there. The only things I can think of is maybe if doesn't like that my dev enviroment ends in .com even though I have forceEnabled as true. I'm not the best at websevers but what I do know about this, is that it is nginx, and when I look at my access log I see debug-kit/toolbar/IDWOULDBEHERE being registered there. It just never makes it into the return function() { in logAjaxRequest.

boyerdalton avatar Jan 09 '21 07:01 boyerdalton

@boyerdalton Its been quite some time but I just wanted to ask if this issue can still be reproduced with the latest version of the DebugKit.

LordSimal avatar Nov 11 '22 17:11 LordSimal