recordAction in code called from modal dialog

This is going to be a bit of a vague question, just hoping that it might ring bells for somebody.

If I trigger some processing from a button on my plugin’s panel and call recordAction at the start of that processing it works just fine.

If I do the same thing, but trigger it from a button on a modal dialog then it’s much less reliable. I can start creating a new action in exactly the same way, and the requested processing on the image completes, but when it fails nothing appears for this processing step in the action that’s being built up.

It works occasionally, and works more often when I’m stepping through the code in a debugger. When it fails in the debugger there is nothing to indicate a failure; the code is in a try/catch and nothing is getting caught.

The debugger issue suggested a timing issue to me, but I’ve double-checked all the async/await. I’ve also tried the dialog close command both before and after calling recordAction.

I’ve tried in Photoshop 25.2 and 25.12, which seem to be the same.

Any suggestions very welcome!

Just managed to find time to get back to this one. Following on with the thought that the problem is possibly timing-related I’ve changed the order of processing.

I started by calling recordAction before the bulk of the work. I’ve now moved recordAction to the end of the processing and I can no longer trigger it to go wrong.

I’m pretty sure this is a bug/quirk/oversight/whatever in Photoshop code; it doesn’t start listening for recordAction soon enough after the user clicks a button on a modal dialog.