Handling "AppleEvent timed out"

I’m triggering a macro from a Jenkins server using the “by Shell script” option.

The macro takes 8-10 minutes to complete and ever since the 5th or so time I ran it, I’ve been getting this error message along with the macro stopping execution most of the time:

execution error: Keyboard Maestro Engine got an error: AppleEvent timed out. (-1712)

The same macro doesn’t appear to time out when triggering with a hot key.

How can I avoid this?

I’m using Version 8.0 on this machine.

In your AppleScript (whatever AppleScript that is being executed) that is accessing Keyboard Maestro Engine, include the command:

with timeout of 86400 seconds
   rest of script
end with

Alternatively, depending on Jenkins way of doing things, you could potentially have it run the script asynchronously or otherwise not wait for the results.

I’m not sure I have access to the actual text of the script.

I’m using the trigger “by Shell script” dropdown option provided by the macro in the KM Editor UI.

So I’m calling this from an Execute Shell (Bash command line) in Jenkins:

osascript -e ‘tell application “Keyboard Maestro Engine” to do script “6798D35F-D346-480F-A48A-4808C6C2EDE9”’

The section inside the single quotes is the script. Try something like:

osascript -e 'with timeout of 86400 seconds' -e 'tell application "Keyboard Maestro Engine" to do script "6798D35F-D346-480F-A48A-4808C6C2EDE9"' -e 'end timeout'
1 Like