Error "on performSmartRule (Error: Error: AppleEvent timed out.)" when running a smart rule wit a javascript script every minute

When I apply this rule manually it works without problems:

'use strict';

function renameDocument(record) {
  const app = Application("DEVONthink 3");
  var nameComponents = [];
  // create new name

  let date = app.getCustomMetaData({for: "Datum", from: record});
  if (date) {
    let year = date.getFullYear();
    let month = (1 + date.getMonth()).toString().padStart(2, '0');
    let day = date.getDate().toString().padStart(2, '0');
    nameComponents.push(year + "-" + month + "-" + day);

  nameComponents.push(app.getCustomMetaData({for: "Kontakt", from: record}));
  nameComponents.push(app.getCustomMetaData({for: "Titel", from: record}));

  let newName = nameComponents.filter(Boolean).join(" | "); = newName;
  //console.log("newName: " + newName);

function moveDocument(record) {
  const app = Application("DEVONthink 3");
  const group = "/Dokumente";
  const db = app.getCustomMetaData({for: "Datenbank", from: record});
  if (!db) {
  const groupRecord = app.getRecordAt(`${group}`, {in: app.databases[db]}); 

  if (groupRecord) {
	console.log("group found");
    app.move({record: record, to: groupRecord});

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

  /* Loop over the records selected by the smart rule */
  records.forEach(r => {


/* anonymous self-executing function permits to run this in script editor etc. */
(() => {
  const app = Application("DEVONthink 3");

But when It is triggered by Perform the following action: Every Minute, I receive an error:

14.04.2022, 23:20:10: Rename document and move to group	on performSmartRule (Error: Error: AppleEvent timed out.)

Any ideas?

You could try to remove the anonymous function at the end in the smart rule script.

I have removed the function. I still get:

(Error: Error: AppleEvent timed out.)

It has nothing to do with the script itself. The error occurs even if I don’t change the default script:

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

	records.forEach (r => {

As soon I include a Java Script script in the rule, I get the error:

LOG: Rename document and move to group (on performSmartRule (Error: Error: AppleEvent timed out.))

Any ideas?

I’m afraid not. Haven’t seen that before. About how many records are we talking here?

And is that happening when you run the rule manually or with your once a minute trigger?


The error only occurs when triggered by the once a minute trigger. When I run the rule manually, I don’t get a timeout. I don’t know why. Something must be different when running the rule by the one a minute trigger. :face_with_raised_eyebrow:

Have you tried running a rule with a javascript script using the once a minute trigger?

Nope. I’ve never seen a reason to run a smart rule at a fixed interval.

I tried to re-create your setup: A smart rule (in my case, selecting all documents in the Inbox) that is run every minute. The only action is an JavaScript. I do not see any error messages re time out.

I’m also unable to reproduce any timeout here either.
Select, Control-click, and disable the actions of other smart rules.
Do you see the timeout again?

The only reason I’m using the once a minute trigger, is that there is no trigger for custom meta data.

That is very strange. Currently I cannot reproduce it either, although I haven’t changed anything (except deleting some documents).

I will continue to monitor it. Thank you for your help.

1 Like

Why not Hourly or Daily to minimize the load?

@Lynx have you seen this behavior lately? I’m thinking I’m experiencing the same problem and wondering if you’re still having this issue: Timeout with performSmartRule

@mdbraber I’m still facing this issue. I thought it was a problem due to my local system, because no one could reproduce it. My workaround was setting the trigger of the rule to After Synchronization .

Is the smart rule only triggered every minute or also used by e.g. other smart rules and/or scripts? Does the rule maybe process huge documents and/or are the databases/documents located on a slow network volume?

It is only triggered every minute and not used in other smart rules.

No, it only process one document.

And there is no timeout, when I switch the smart rule to perform After Synchronization .

Does it work after disabling the actions of all other smart rules temporarily (e.g. via the contextual menu of the sidebar)? In addition, please choose Help > Report Bug while pressing the Alt modifier key and send the result to cgrunenberg - at - so that we can have a look at the logs - thanks!



Here is the smart rule:

and the script:

'use strict';

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

  /* Loop over the records selected by the smart rule */
  records.forEach(r => {
    // renameDocument(r)
    // moveDocument(r)


Thank you.

Thank you for the logs! Unfortunately no hints, only a confirmation of the timeouts. And it’s working fine over here using the same macOS version.

Could this not be the same bug as the one you’ve identified (one script waiting for another)?