Sporadic timeouts with embedded scripts

I have a number of smart rules which run daily - they use scripts; it’s relatively common for me to find the following error in the log:

04:07:02: name of smart rule on performSmartRule (AppleEvent timed out.)

I had the same problem when import of specific documents to inbox triggered a relatively complex script; the document was always printed from Safari, so DT was never in the active window when the document arrived. I finally solved that problem by calling the script as an external rather than an embedded script. Before doing that I determined that in the cases where it timed out, the script never got past tell application id "DNtp". It was also interesting to note that regardless of any setting for the timeout, when it timed out the script timed out within seconds.

Is there any reason why an embedded script would time out, whilst an otherwise identical external script does not? Would an activate command in the embedded script make a difference? Any other bright ideas how to solve the problem of sporadic timeouts (and they are sporadic)?

Thanks for your comments and ideas :slight_smile:

Scripts are always executed the same way, only their location (embedded vs. external) is different. An activation shouldn’t make a difference either, the app is already running and that’s sufficient. What’s the code of the script?

I’ll PM you the code in this case, if you don’t mind.

No problem.

Thanks for your feedback, which included the tip to reconsider using a dialog in a smart rule, which you suggest should instead run without user intervention. Whilst I’ll be sticking will dialogs in some of my scripts, I agree that using them in scripts which trigger automatically even when the user is not at the Mac is a problem. Can I output to the log from a script?

Yes, see log message command.

1 Like