Timeout with performSmartRule

It’s a timeout caused by one AppleEvent waiting for another one. The next release will include a workaround but actually it’s recommended to directly call the scripts in this case instead of indirectly via smart rules.

1 Like

@cgrunenberg thanks for identifying the bug. I’ll check how I can run the script directly. Does this mean you’re actually advising against calling perform smart rule or app.performSmartRule() with smart rules running external scripts?

Yes, that’s recommended.

I forgot to add probably, but the timeout also happens when the smart rule is triggered by anything other than ‘on demand’ (same problem as @Lynx). So e.g. it also times out when “On import” is triggered because an item is added to the Inbox. So I’m eagerly awaiting the fix in the next release (or would there be a beta version to use / test)?

It’s unclear how it’s triggered. Still via perform smart rule?

No it is triggerd via the Actions of the smart rule itself (e.g. On Import, On Creation etc)

In that case it might be an issue of the used script and that it requires too much time for the default AppleEvents timeout of 60 seconds. Using a with timeout of x seconds ... end timeout block might fix this.

Thanks. I’ll investigate also!

@cgrunenberg I’ve checked this a bit further, but the problem persists with normal triggers (e.g. Before Synchronization) even with this simple example (internal) JXA script:

function performsmartrule(records) {
	var app = Application("DEVONthink 3");
	app.includeStandardAdditions = true;

	records.forEach (r => {
		app.logMessage("Test");
	})
}

I have also checked this on a different machine with 3.8.6 installed and the exact same thing happens with this test script when triggered by any other trigger than On Demand. Also - this does not happen when triggering an (internal) AppleScript, it happens only with JXA. The timeout does not happen when using the script on demand.

And how many items does the rule process? A screenshot of the conditions would be useful.

Just tried this using a smart rule which is performed every minute, no timeouts after several minutes and the script was executed every minute.

Tested this with one Markdown document with just the contents “Test”



Tried exactly the same and it consistently times out. I’ve removed all other Smart Rules to be sure there’s no interference from other rules…

Which macOS version do you use? Does it work after booting the Mac in safe-mode or using a new, clean user account? My system is always plain vanilla.

macOS 12.6 (Monterey). Just booted into safe mode and same behavior. Also on the other
machine which already basically only runs DT (also Monterey)

I’m wondering if this is a regression in 3.8.6? It didn’t seem to happen on 3.8.5. But I’m curious if other who use JXA scripts like @chrillek are also experiencing the same?

EDIT: digging a bit deeper. It seems that triggers like “On renaming”, “On flagging” or “On import” don’t cause a timeout. Triggers like “Every minute” or “Before synchronization” do.

EDIT2: even more interesting: there is no timeout with the trigger “After synchronization” (consistent with what @Lynx reported), but there is a timeout with the trigger “Before synchronization”. There is also no timeout “On startup” - but there is a timeout “On Quit”

To summarize - the triggers which cause a timeout seem to be:

  • Every minute (I haven’t tried the other timers)
  • Before synchronization
  • On quit

So far all other triggers I have tested seem to be doing okay

Does this still happen without any additional smart rules or reminders? In that case a sample of the app would be useful, thanks.

@mdbraber I’m glad that someone could reproduce my error. It’s strange that it seems to depend on the trigger type.

I’m wondering if that might be a race condition. Like the 2nd 1 minute trigger starting before the 1st one finished. Or the on quit not waiting till the rule has finished.

Just a wild shot.

As to your question: No, I’m not experiencing that. But I’m only using on demand triggers and never use performSmartRule.

2 Likes