clockwork icon indicating copy to clipboard operation
clockwork copied to clipboard

commandExecuted - no output in extension

Open mattvb91 opened this issue 2 years ago • 5 comments

I have clockwork registered in vanilla php and at the end of my script im running:

$clockwork->commandExecuted('test')

now when i run php test.php I can see the json meta file created and when i visit __clockwork/handle?request=latest I can see the output:

{
"id": "1701184009-5775-1312652186",
"version": 1,
"type": "command",
"time": 1701184009.577506,
"method": null,
"url": "[http://:](http:///)",
"uri": null,
... //truncated
}

However it never shows up in the extension under dev tools? I feel like im missing something obvious?

http requests are working fine.

--- edit

For anyone else that lands here. In the settings you can enable commands etc.. Screenshot 2023-11-28 at 17 39 19

However nothing shows up still..

mattvb91 avatar Nov 28 '23 15:11 mattvb91

Hey, I've fixed a bug, that could cause non-http requests to not show up in the Clockwork extension. Can you give dev-master a try?

itsgoingd avatar Dec 10 '23 19:12 itsgoingd

locally it works fine on dev-master. @itsgoingd I had to switch to the following config to make it work in the meanwhile:

   'storage_files_path' => sys_get_temp_dir() . '/clockwork',

Could the issue I was having have something to do with my server using an efs mount before and your change fixes that? Does it sound remotely like your fix?

mattvb91 avatar Dec 12 '23 10:12 mattvb91

Not really. To show commands in the extension, we take the last shown request's id and then poll the Clockwork rest api that's part of your app, to return any command-type requests newer than that id.

To do this, we have an index file with all collected request ids and types, where we find that particular id and then search it forward and return all newer command-type request ids, this is what it looks like:

1702234464-8013-1871081223,1702234464.8006,GET,/,,200,11.873006820679,request   <- Last request shown in extension, start search here.
1702234465-0138-827968,1702234465.0131,GET,/,,200,7.1418285369873,request   <- Not a command, skip
1702234468-8185-170173831,1702234468.8185,,test,,,7.54714012146,command   <- Command, show

Due to a bug in the code though, this search would stop once a first non-command request id is encountered, instead of it being skipped.

This means, it would work fine in many cases, if you are the only user of the app. But as soon as another HTTP request from other browser tab, would be received after the last shown request in the extension, it would fail on this request and never reach the command entry.

itsgoingd avatar Dec 16 '23 21:12 itsgoingd

aah we have a lot of image tags being rendered out from the initial request which in turn hit php again in dev mode to resize images so it may have had something to do with all the other requests coming in as you said! Thanks

mattvb91 avatar Dec 17 '23 07:12 mattvb91

@itsgoingd any chance you can add a new tag? thank you! 🥳

mattvb91 avatar Jan 12 '24 15:01 mattvb91

Fix included in Clockwork 5.2.

itsgoingd avatar Feb 21 '24 20:02 itsgoingd