itsgoingd / clockwork-chrome

Clockwork - php dev tools integrated to your browser - Chrome extension
https://underground.works/clockwork
411 stars 25 forks source link

clockwork requests data but don't display #20

Closed kodl closed 7 years ago

kodl commented 7 years ago

Hello .. I'm developing Lavarel API (using Dingo)

When I call in browser /dev/path/server/public/api/wps, I see in apache access log request to /dev/path/server/public/__clockwork/1480681244.3731.1135877235 In browser I see JSON result, but in clockwork see nothing

Any Idea why?

Thanks for help


raw JSON:  {"id":"1480681244.3731.1135877235","version":1,"time":1480681244.285,"method":"GET","uri":"\/dev\/path\/server\/public\/api\/wps","headers":{"host":["192.168.100.222"],"connection":["keep-alive"],"cache-control":["max-age=0"],"upgrade-insecure-requests":["1"],"user-agent":["Mozilla\/5.0 (Windows NT 10.0; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/54.0.2840.87 Safari\/537.36"],"accept":["text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,*\/*;q=0.8"],"accept-encoding":["gzip, deflate, sdch"],"accept-language":["cs-CZ,cs;q=0.8"],"cookie":["adminer_version=0; PHPSESSID=mhbu892vv1t0p1t0amlguncsk1; nette-browser=0169ngb2qx; _ga=GA1.1.1482508004.1477558523; _gat=1; XSRF-TOKEN=eyJpdiI6IklHMmxLRHpNQW1pTERQS08zbjRqalE9PSIsInZhbHVlIjoiUlNRRGt6K3JUMmZiMTZtNlo4WjZUWDE4blF1TWpLZ3pRNnp4ZWVLVFZiRDVUejFuMWR5T2g1UHI4MlpTNnUzSW9oQVdEbXRibmVuNjNkTkNhMGlCVVE9PSIsIm1hYyI6ImQwNzI4ZDdmZGE0YzM5MzA2YTk3YTdhYmIxNjczNWE1ZGE3YmMyNmY5M2VjMzMxZDllODBiN2FkYzBlYmM3NDAifQ%3D%3D; laravel_session=eyJpdiI6ImpYRnpjcUU2TEgwXC9ONFZwdDUzOGlnPT0iLCJ2YWx1ZSI6IisxRDQ1UHpIVjBJeEtkQzRhcWtyRCtsR0x0eCs1S0N5anJ1TkxQeHdLeW1XbmRkNGhWdW1QTHM1NUtkNW5jR1J2eWpQTmI3WlRNU1lpajFtRlNwbmp3PT0iLCJtYWMiOiIzMzVkNDJhNzU2NTZmZWRlNTMzNTBkZDczMDZkZmFmYmEyY2Y3NDhkZGY2YjNhM2E1MzVjYTQ4YWY3Y2JkNzk5In0%3D"]},"controller":null,"getData":[],"postData":[],"sessionData":[],"cookies":{"adminer_version":"0","PHPSESSID":"mhbu892vv1t0p1t0amlguncsk1","nette-browser":"0169ngb2qx","_ga":"GA1.1.1482508004.1477558523","_gat":"1","XSRF-TOKEN":"eyJpdiI6IklHMmxLRHpNQW1pTERQS08zbjRqalE9PSIsInZhbHVlIjoiUlNRRGt6K3JUMmZiMTZtNlo4WjZUWDE4blF1TWpLZ3pRNnp4ZWVLVFZiRDVUejFuMWR5T2g1UHI4MlpTNnUzSW9oQVdEbXRibmVuNjNkTkNhMGlCVVE9PSIsIm1hYyI6ImQwNzI4ZDdmZGE0YzM5MzA2YTk3YTdhYmIxNjczNWE1ZGE3YmMyNmY5M2VjMzMxZDllODBiN2FkYzBlYmM3NDAifQ==","laravel_session":"eyJpdiI6ImpYRnpjcUU2TEgwXC9ONFZwdDUzOGlnPT0iLCJ2YWx1ZSI6IisxRDQ1UHpIVjBJeEtkQzRhcWtyRCtsR0x0eCs1S0N5anJ1TkxQeHdLeW1XbmRkNGhWdW1QTHM1NUtkNW5jR1J2eWpQTmI3WlRNU1lpajFtRlNwbmp3PT0iLCJtYWMiOiIzMzVkNDJhNzU2NTZmZWRlNTMzNTBkZDczMDZkZmFmYmEyY2Y3NDhkZGY2YjNhM2E1MzVjYTQ4YWY3Y2JkNzk5In0="},"responseTime":1480681244.4441,"responseStatus":200,"databaseQueries":[{"query":"SELECT * FROMw01_work_packages","duration":14.15,"connection":"mysql","file":"\\app\\Http\\Controllers\\WorkPackageController.php","line":12,"model":"App\\WorkPackage"},{"query":"SELECT * FROMw01_work_packagesWHEREw01_work_packages.w01_work_package_idin ('1')","duration":0.49,"connection":"mysql","file":"\\app\\Http\\Controllers\\WorkPackageController.php","line":12,"model":"App\\WorkPackage"},{"query":"SELECT * FROMw02_package_typesWHEREw02_package_types.w02_package_type_idin ('1')","duration":0.47,"connection":"mysql","file":"\\app\\Http\\Controllers\\WorkPackageController.php","line":12,"model":"App\\WorkPackageType"}],"timelineData":{"total":{"start":1480681244.285,"end":1480681244.4462,"duration":161.20886802673,"description":"Total execution time.","data":[]},"initialisation":{"start":1480681244.285,"end":1480681244.3537,"duration":68.652868270874,"description":"Application initialisation.","data":[]},"boot":{"start":1480681244.3537,"end":1480681244.3976,"duration":43.899059295654,"description":"Framework booting.","data":[]},"run":{"start":1480681244.3537,"end":1480681244.4462,"duration":92.555046081543,"description":"Framework running.","data":[]}},"log":[{"message":"Message text.","context":"[]","level":"debug","time":1480681244.4089,"file":"\\app\\Http\\Controllers\\WorkPackageController.php","line":11}],"routes":[],"emailsData":[],"viewsData":[],"userData":null,"responseDuration":159.09600257874,"databaseDuration":15.11}

kodl commented 7 years ago

for better readin sending parsed JSON:

{
"id": "1480681244.3731.1135877235",
"version": 1,
"time": 1480681244.285,
"method": "GET",
"uri": "/dev/path/server/public/api/wps",
"headers": {
"host": [
"192.168.100.222"
],
"connection": [
"keep-alive"
],
"cache-control": [
"max-age=0"
],
"upgrade-insecure-requests": [
"1"
],
"user-agent": [
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36"
],
"accept": [
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
],
"accept-encoding": [
"gzip, deflate, sdch"
],
"accept-language": [
"cs-CZ,cs;q=0.8"
],
"cookie": [
"adminer_version=0; PHPSESSID=mhbu892vv1t0p1t0amlguncsk1; nette-browser=0169ngb2qx; _ga=GA1.1.1482508004.1477558523; _gat=1; XSRF-TOKEN=eyJpdiI6IklHMmxLRHpNQW1pTERQS08zbjRqalE9PSIsInZhbHVlIjoiUlNRRGt6K3JUMmZiMTZtNlo4WjZUWDE4blF1TWpLZ3pRNnp4ZWVLVFZiRDVUejFuMWR5T2g1UHI4MlpTNnUzSW9oQVdEbXRibmVuNjNkTkNhMGlCVVE9PSIsIm1hYyI6ImQwNzI4ZDdmZGE0YzM5MzA2YTk3YTdhYmIxNjczNWE1ZGE3YmMyNmY5M2VjMzMxZDllODBiN2FkYzBlYmM3NDAifQ%3D%3D; laravel_session=eyJpdiI6ImpYRnpjcUU2TEgwXC9ONFZwdDUzOGlnPT0iLCJ2YWx1ZSI6IisxRDQ1UHpIVjBJeEtkQzRhcWtyRCtsR0x0eCs1S0N5anJ1TkxQeHdLeW1XbmRkNGhWdW1QTHM1NUtkNW5jR1J2eWpQTmI3WlRNU1lpajFtRlNwbmp3PT0iLCJtYWMiOiIzMzVkNDJhNzU2NTZmZWRlNTMzNTBkZDczMDZkZmFmYmEyY2Y3NDhkZGY2YjNhM2E1MzVjYTQ4YWY3Y2JkNzk5In0%3D"
]
},
"controller": null,
"getData": [],
"postData": [],
"sessionData": [],
"cookies": {
"adminer_version": "0",
"PHPSESSID": "mhbu892vv1t0p1t0amlguncsk1",
"nette-browser": "0169ngb2qx",
"_ga": "GA1.1.1482508004.1477558523",
"_gat": "1",
"XSRF-TOKEN": "eyJpdiI6IklHMmxLRHpNQW1pTERQS08zbjRqalE9PSIsInZhbHVlIjoiUlNRRGt6K3JUMmZiMTZtNlo4WjZUWDE4blF1TWpLZ3pRNnp4ZWVLVFZiRDVUejFuMWR5T2g1UHI4MlpTNnUzSW9oQVdEbXRibmVuNjNkTkNhMGlCVVE9PSIsIm1hYyI6ImQwNzI4ZDdmZGE0YzM5MzA2YTk3YTdhYmIxNjczNWE1ZGE3YmMyNmY5M2VjMzMxZDllODBiN2FkYzBlYmM3NDAifQ==",
"laravel_session": "eyJpdiI6ImpYRnpjcUU2TEgwXC9ONFZwdDUzOGlnPT0iLCJ2YWx1ZSI6IisxRDQ1UHpIVjBJeEtkQzRhcWtyRCtsR0x0eCs1S0N5anJ1TkxQeHdLeW1XbmRkNGhWdW1QTHM1NUtkNW5jR1J2eWpQTmI3WlRNU1lpajFtRlNwbmp3PT0iLCJtYWMiOiIzMzVkNDJhNzU2NTZmZWRlNTMzNTBkZDczMDZkZmFmYmEyY2Y3NDhkZGY2YjNhM2E1MzVjYTQ4YWY3Y2JkNzk5In0="
},
"responseTime": 1480681244.4441,
"responseStatus": 200,
"databaseQueries": [
{
"query": "SELECT * FROM `w01_work_packages`",
"duration": 14.15,
"connection": "mysql",
"file": "\\app\\Http\\Controllers\\WorkPackageController.php",
"line": 12,
"model": "App\\WorkPackage"
},
{
"query": "SELECT * FROM `w01_work_packages` WHERE `w01_work_packages`.`w01_work_package_id` in ('1')",
"duration": 0.49,
"connection": "mysql",
"file": "\\app\\Http\\Controllers\\WorkPackageController.php",
"line": 12,
"model": "App\\WorkPackage"
},
{
"query": "SELECT * FROM `w02_package_types` WHERE `w02_package_types`.`w02_package_type_id` in ('1')",
"duration": 0.47,
"connection": "mysql",
"file": "\\app\\Http\\Controllers\\WorkPackageController.php",
"line": 12,
"model": "App\\WorkPackageType"
}
],
"timelineData": {
"total": {
"start": 1480681244.285,
"end": 1480681244.4462,
"duration": 161.20886802673,
"description": "Total execution time.",
"data": []
},
"initialisation": {
"start": 1480681244.285,
"end": 1480681244.3537,
"duration": 68.652868270874,
"description": "Application initialisation.",
"data": []
},
"boot": {
"start": 1480681244.3537,
"end": 1480681244.3976,
"duration": 43.899059295654,
"description": "Framework booting.",
"data": []
},
"run": {
"start": 1480681244.3537,
"end": 1480681244.4462,
"duration": 92.555046081543,
"description": "Framework running.",
"data": []
}
},
"log": [
{
"message": "Message text.",
"context": "[]",
"level": "debug",
"time": 1480681244.4089,
"file": "\\app\\Http\\Controllers\\WorkPackageController.php",
"line": 11
}
],
"routes": [],
"emailsData": [],
"viewsData": [],
"userData": null,
"responseDuration": 159.09600257874,
"databaseDuration": 15.11
}
itsgoingd commented 7 years ago

Hey, the Clockwork metadata request is done via ajax, is there any chance you have eg. some middleware (maybe as part of the Dingo package) or some other code that would cause such requests to be processed differently than normal requests from browser?

You might also want to try to reinstall the extension, that seems to magically fix these kinds of issues sometimes.

kodl commented 7 years ago

I've tried reinstallation twice - ;) Could you show me settings of the Ajax request (headers etc)? I'll try to simulate it in Postman to see if it is different. Is there any way how to debug it or to find some log?

itsgoingd commented 7 years ago

Actually they won't be identified as ajax requests since we no longer use jquery, an example request might look like this:

GET /__clockwork/1480701276.5868.260466343 HTTP/1.1
Host: localhost:8000
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2926.0 Safari/537.36
Accept: */*
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8,sk;q=0.6,cs;q=0.4

If you want to debug the extension further, you can click on "Inspect views: background page" under Clockwork in the Chrome addons view, this will open dev tools for the extension itself, here you can check for any errors in the console and try adding some breakpoints to the background.js script where the ajax request is made.

kodl commented 7 years ago

VM201:1 Uncaught SyntaxError: Unexpected token  in JSON at position 0 at JSON.parse (<anonymous>) at XMLHttpRequest.xhr.onreadystatechange (chrome-extension://dmggabnehkmmfmdffgajcflpdjlnoemp/assets/javascripts/background.js:10:20)xhr.onreadystatechange @ background.js:10 .. I found, that problem is, that my json result have coding UTF-8 with BOM (don't know why yet) Is it possible to check/ignore BOM characters on begining of result?

itsgoingd commented 7 years ago

What might be happening is that one of your PHP files might contain BOM and it's sent to the browser as soon as the file is parsed (since it's encountered before the opening php tag). Try checking your codebase with find or grep (http://stackoverflow.com/a/2858757, make sure to remove the rm call form the example though :).

kodl commented 7 years ago

Of course, I'll find and remove all BOMs in my code. But it would be nice (for future users) to modify clockworks to ignore that characters ..

Mainly, thank you for your help with identifying the problem .. 👍