On performSmartRule (AppleEvent timed out.)

I have a smart rule with a script. I want it to process all items so I set it to run on clip and after sync (I clip in DTTG and want those items to be processed too).

When I clip on my mac the script runs fine. However, when the rule is triggered after sync it times out.

on performSmartRule (AppleEvent timed out.)

The script is partially executed. The timeout is not too long either. On the order of a second. The message appears in the log almost instantly after I click the sync button.

Is there anything I can do to extend the timeout period?

You could put your code in a…

with timeout of x seconds
end timeout

…block.

I can’t put it around on performSmartRule and putting it around the body of the event handler doesn’t seem to have any effect.

How does the complete script look like?

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set theURL to URL of theRecord
			set theName to name of theRecord
			if theURL begins with "http:" or theURL begins with "https:" then
				set theParents to parents of theRecord
				
				set versions to lookup records with URL theURL in database of theRecord without theRecord
				set preserved to false
				repeat with theVersion in versions
					if type of theVersion is "webarchive" then
						set preserved to true
					end if
				end repeat
				
				if not preserved then
					set theCopy to create web document from theURL name theName in (item 1 of theParents)
					repeat with i from 2 to (count of theParents)
						replicate record theCopy to (item i of theParents)
					end repeat
					set creation date of theCopy to creation date of theRecord
					set comment of theCopy to comment of theRecord
					set rating of theCopy to rating of theRecord
					set label of theCopy to label of theRecord
					set state of theCopy to state of theRecord
					set tags of theCopy to tags of theRecord
					set state of theCopy to state of theRecord
					set locking of theCopy to locking of theRecord
					set unread of theCopy to unread of theRecord
				else
					log message theName info "Is already preserved locally"
				end if
				
				try
					move record theRecord to trash group of database of theRecord
				on error error_message number error_number
					log message theName info "Could not move original item to Trash"
				end try
			else
				log message "URL is not on the web: " & theURL
			end if
		end repeat
	end tell
end performSmartRule

The idea is to convert all bookmarks to webarchieves. I have smart rule for this script to run on a specific group of a specific database. The rule is applied on clip and after synchronization.

To see the issue, clip a bookmark in DTTG and sync first in DTTG, then in DTP3. That is if this is not an issue with my machine. I sync over WebDAV, in case that is important.

Did you try to add a timeout block enclosing only the create web document command? How long was the timeout?